Small Error Gap But Big
Hi, my site requires users to complete a certain task on the site everyday before the end of the day 23:59:59 (don't worry about timezones or the task)
The task has a $today_status (complete or incomplete)
I have a cron that runs at the start of the day (00:00:01) to do 2 things:
01 - check if all tasks were completed yesterday (check for all tasks that are still incomplete)
02 - reset all of yesterdays tasks back to incomplete so the user can start the task again today (for the new day)
Each task has a count down timer displayed next to it so that the user can see one of the following two timers:
A (IF $today_status = incomplete) - the time they have left to complete the task (counting down to the end of the day)
B (IF $today_status = complete) - the time they have to wait before they can complete the second task (counting down to the end of the day)
I have 2 small problems that are related:
The crons runs as soon as it turns into a new day at 00:00:01 however the cron not might finish processing all of the tasks until 00:07:19 so there is a 7 min error gap... this could increase as more users join.
So, if the user has completed the task for the previous day, and then views the task at 00:03:27 the next day... $today_status could still be 'completed' as the cron might not have processed it for the previous day yet... and there for the timer will say
(time left to wait before you can start the next task)
It will say the above because it is still in 'complete' status... however the user just logged in early so they could complete today's task early BUT the site is telling them otherwise... it is telling them they have to wait until tomorrow to complete the next task...
I hope i am explaining this correctly and thank you so much if you have bothered to read down this far... any help will be greatly appreciated... thanks in advance
Instead of a flag saying whether its completed or not and a cron to reset the flag, you could use a datetime column to track the last completed time, then to determine if they can complete it today or not would be as simple as seeing if the last time they completed it was today. There would be no delay, they could do it at 23:59:59 and again at 00:00:01 you just have to keep track of the date with it.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)