We noticed in our reports that when looking at statistics for "Yesterday", we only see 0/0 and not the actual reports being clicked. After looking at the code, we saw this as the culprit:
WHERE STR_TO_DATE(sc.date, '%Y%m%d') <= NOW() AND STR_TO_DATE(sc.date, '%Y%m%d') >= SUBDATE(NOW(), INTERVAL 1 DAY)
This pulls the date value from simplead_stats and compares it to the time right now. The date value is set by a cron job that limits it to a 'Ymd' format with no timestamp, but that's a different story, so we only know the daily aggregate. To break this down into verbal terms, let's say the summary is for 09-03-2015 and we're looking at this at 10:45 am on 09-04-2015.
WHERE (09-03-2015 00:00:00 <= 09-04-2015 10:45:00) AND (09-03-2015 00:00:00 >= 09-03-2015 10:45:00)
The above will fail every time because there are no results that fit that value, unless I'm looking at something wrong or we don't have enough data. Now there are 2 ways we can approach this:
1) Return all values in the past 24 hours
2) Return all values between 00:00:00 (midnight) the day before and the day after.
Option 2 seems to make the most sense, so that's the patch I'm proposing. If any of you have seen this, or know if it's supposed to work differently, please let me know just so we can get a better understanding of how it works.
WHERE STR_TO_DATE(sc.date, '%Y%m%d') <= CURDATE()
Comment | File | Size | Author |
---|---|---|---|
#5 | change-date-format-pull-correct-yesterday-2563433-3.patch | 2.31 KB | 3magnus |
#3 | change-date-format-pull-correct-yesterday-2563433-2.patch | 2.32 KB | 3magnus |
| |||
#2 | change-date-format-pull-correct-yesterday-2563433-1.patch | 2.03 KB | kyletaylored |
|
Comments
Comment #2
kyletaylored CreditAttribution: kyletaylored at LevelTen Interactive commentedComment #3
3magnus CreditAttribution: 3magnus commented@kyletaylored what your patch does is to get all stats (All Time) and put it under Yesterday.
I've changed the same lines from:
to:
and got the results.
Always here to help.
Comment #4
3magnus CreditAttribution: 3magnus commentedI've changed again the same lines from:
to:
because it makes more sense. The results I've got were the same, though.
Always here to help.
Comment #5
3magnus CreditAttribution: 3magnus commentedComment #6
tomrogI've changed the yesterday code lines to:
WHERE STR_TO_DATE(sc.date, '%Y%m%d') <= NOW() AND STR_TO_DATE(sc.date, '%Y%m%d') >= CURDATE() - 1
so I think CURDATE() can be used in second conditions as well ;)
Comment #7
joshuautley CreditAttribution: joshuautley commentedI can confirm #6 works for me.
Comment #8
szt CreditAttribution: szt commentedComment #12
sarathkm#6 applied
Thanks :)