PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2012, 09:51 AM
oo7ml oo7ml is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 189 oo7ml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 34 sec
Reputation Power: 2
Small Error Gap Which Is 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

23:54:33
(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

Reply With Quote
  #2  
Old December 6th, 2012, 09:59 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,875 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 5 Days 22 h 11 m 34 sec
Reputation Power: 581
OK, so what does any of this have to do with PHP?
__________________
There are 10 kinds of people in the world. Those that understand binary and those that don't.

Reply With Quote
  #3  
Old December 6th, 2012, 10:03 AM
oo7ml oo7ml is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2011
Posts: 189 oo7ml User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 55 m 34 sec
Reputation Power: 2
Thank you for reading...

To answer your question... hopefully someone who programs in PHP can advise on a better solution or fix... in "PHP"

Reply With Quote
  #4  
Old December 6th, 2012, 10:19 AM
ManiacDan's Avatar
ManiacDan ManiacDan is offline
Likely to be eaten by a grue.
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Oct 2006
Location: Pennsylvania, USA
Posts: 9,791 ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)ManiacDan User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1Folding Points: 127430 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Months 3 Weeks 14 h 53 m 20 sec
Reputation Power: 6112
Store the most recent timestamp the task was complete. That way your code can know if "today's" task was actually completed today, since you'll have the timestamp of that user's task to compare to the current time.
__________________
HEY! YOU! Read the New User Guide and Forum Rules

"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

"The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

Reply With Quote
  #5  
Old December 6th, 2012, 10:19 AM
gw1500se gw1500se is offline
Contributing User
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jul 2003
Posts: 2,875 gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level)gw1500se User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 1 Year 1 Week 5 Days 22 h 11 m 34 sec
Reputation Power: 581
I see no PHP to fix or advise. However, I can give you a general suggestion. When the cron job starts set a flag somewhere that your page can read. If set have your page output a notice, rather than task data, indicating the data is being updated and to please try later. Once the cron job finishes clear that flag.

Reply With Quote
  #6  
Old December 7th, 2012, 12:04 AM
ingobauer ingobauer is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 2 ingobauer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 45 m 21 sec
Warnings Level: 15
Number of bans: 1
Reputation Power: 0
I can only think of a workaround. As the cron will be more and more slow, then you could add a "last_cron_date" field that will show you when have the cron last time fixed the given task. Thus in the UI you will check if the task has been passed by the cron TODAY, and if so display the remaininng. If the cron has not yet reached this task, its date field will still be yesterday, and you can handle this properly - either say "this task is being currently handled", or allow it to be handled or whatever you decide to do for the handling time gap.

Last edited by requinix : December 7th, 2012 at 01:09 AM. Reason: removed spam

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Small Error Gap Which Is Big

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap