Can i run a background task timing based on relative data or database variable?
Options
![Jay](https://us.v-cdn.net/6037124/user_avatars/2364889.jpg)
Jay
Member ✭
Just in case there is a better way to do this all together I'll spell out what I'm trying to do and then ask my specific question.
I have a table of users, each has an allotment of 3 posts per day, saved as post_count in the user table, when they post it gets incremented down, when it is zero, they can't post again until tomorrow.
I want, at each user's local time at midnight, to reset the count to 3. Is this possible? if so, how?
Otherwise, how might I accomplish this?
I have a table of users, each has an allotment of 3 posts per day, saved as post_count in the user table, when they post it gets incremented down, when it is zero, they can't post again until tomorrow.
I want, at each user's local time at midnight, to reset the count to 3. Is this possible? if so, how?
Otherwise, how might I accomplish this?
Comments
-
Hey definitely possible. I imagine there's at least a few different approaches here.
One idea - first, you'd need to store each user's timezone. You can Query All Records from user (using the stream return type) and For Each Loop through those records. Then have a Conditional... WHERE now (format_timestamp using the user's timezone, so var: item.timezone) == 12am (or however you format the timestamp)... THEN reset the count on the user...
You might want to make the Conditional WHERE statement be more inclusive of a few minutes from midnight to just past it, in order to give the background task full time to run.
The task would probably run every 30 minutes (I think) to cover the wide-range of timezones.
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