What I am Wanting to Accomplish
You know how a lot of apps reward you for logging in and collecting some type of bonus that becomes available every 24 hours? I'm trying to figure out how to build that in Xano/WeWeb.
I'm wanting to gamify my site a little bit that will reward users w/ points for certain actions that then enter them into a monthly giveaway. One of the 'actions' would be visiting my site (logged in) every 24 hours.
On a special page I want to have a button that as soon as they press it rewards points and then (ideally) shows a message that says something like 'Come back at [DATE & TIME] to claim your next bonus!' where the button will re-enable and allow them to collect.
The Stumbling Block
Clicking the button and causing that API request to add points to an existing value is simple, but the timer is trickier. I'm guessing I would have a separate true/false
field that would dictate whether the button would be clickable. So as soon as points are added, the 'allow' field would switch from true
to false
and then…..that's where I could use some vision.
Some Possible Theories
I'm guessing I would have a timestamp field that would stamp when the button was last clicked. But what would be the most efficient way for Xano to know to flip that 'allow' value to true
after 24 hours?
Running a background task across my database every 10 seconds doesn't seem efficient as the userbase grows. Perhaps when the user's page is loaded on the WeWeb side, an API call is automatically made that runs a check? Essentially the function would look to see if it's been 24 hours since the timestamp and if so, it would update the 'allow' field to true
?
If that's the case, I suppose my only question is how in Xano can I check to see if it's been a certain amount of time since a timestamp?