Dynamic function scheduling
Options
![Mauro Mequelussi-1595850](https://us.v-cdn.net/6037124/user_avatars/1595850.jpg)
Mauro Mequelussi-1595850
Member ✭
It would be interesting to be able to dynamically schedule a time for a function to run.
For example, the user registers to receive an alert at a certain time. In this case, the function could be scheduled to run the function that triggers the alert at the time the user requested.
As far as I know, we can only schedule one function to run at a fixed time.
Comments
-
You can just record the alert in the database and on your background task search for records where the registered alert is equal to now or between now and for example +1 minute. Then just have this task run every minute or as granular as the user is allowed to schedule alerts.
-
So if you had multiple alerts in many tables, would you have one task that searches many tables?
For example, a task searches for and does the following every minute:
• Goal table: If Goal's end_date is NOW, set Goal's active_status to false
• Goal table: if Goal start_date is NOW, set Goal's active_status to true
• User table: if User's active_goal_id is null, do XYZ
• Chat table: if Chat's created_at is NOW, notify user
• etc.
Here are a couple other questions stemming from the above example:
1. The User table example seems like it won't work because it's not based a state rather than a time. So if the task ran every minute and the active_goal was null, it would run repeatedly rather than once.
2. For the Goal examples, the start_date and end_date are dates, not timestamps. Would I want to include those in a separate task that searches for records based on date rather than timestamp? -
- I probably would have multiple tasks depending on the nature of each query+notification combo but I do suppose you could it all in one depending on how often you look to run it.
I'm not exactly clear on your first question/have enough context. How are you querying the records? Why can't you filter out the null values?
I would consider using relative time format for working with dates (i.e. today, tomorrow, yesterday, etc.)
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback