Hi Everyone!
I’m building a feature that involves scheduled tasks. I'd love to hear your ideas and opinions on how to better implement it.
1. Scenario:
open only when that scheduled date comes. Until then, it will be marked closed.closed again.2. Prerequisites:
I’m using the following technologies:
3. Initial Plan:
3.1. I will create a separate database for the Task Queue. Any new tasks scheduled by users will also be stored here. Task and User data are stored on different databases respectively.
3.2. I will create a function that is scheduled to run everyday at 00:00:00. On the event that this function fires, it will do 2 things:
3.2.1. It will check today’s date and retrieve the collection from the Task Queue database with that same date. The function will then go over each task and mark it open for that day.
3.2.2. It will also retrieve yesterday’s task queue, go over those tasks and mark them closed.
4. Questions:
I know there's a much more effective and efficient way of setting this up so I'm looking forward to everyone's feedback. Any links/resources for further reading will be awesome. Thank you in advance!
4.1 - I wouldn't overthink things here. I'm not familiar with Firebase RDB, but I'd simply save each task and then index the DB on dates. You'd probably have to hit millions of records to start running into performance issues, and at that point you can always run cleanup scripts to archive old data.
4.2 - It depends on the use case. If the tasks are only by day then running it once per day might be fine. If I can get more granular (this day between 1-2) you'll need to run it more often.
4.3 - Save the users time zone and convert any times to UTC before saving to the DB. You can then properly format it for the user when you return it to them.
Gotcha. Thanks for the feedback! Totally agree on not overthinking things. It's much more important to just get it out there asap.
4.3. You can convert user-input timezones into UTC timezone before storing it in your DB
Ref: https://stackoverflow.com/questions/42842134/handling-multiple-timezones-in-application
Noted. Thank you for the insight!