New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix check if the difference between start and end date is a day #13315
Fix check if the difference between start and end date is a day #13315
Conversation
Issue: matomo-org#13047 The check does not take into consideration range period, where if you have two adjusent days, it's 47h59m59s and not a day.
Many thanks for digging into this, @tzhelyazkova! |
Thanks for the PR and research @tzhelyazkova, it's very much appreciated! I think you definitely found a bug here, but I'm not sure it's the cause of @KaiNissen's issue. The code here is part of the code that aggregates log data: it checks if the period is for a single day & site, and if so aggregates the log data. If it isn't, it means the period spans multiple days and the archiver will initiate archiving for each individual day and then aggregate the results for the whole period. @KaiNissen's issue sounds like pre-archived data from pre-3.0 versions aren't being found for ranges that consist of two adjacent days, so I'm not sure what effect this will have. @KaiNissen are you able to confirm if this fixes the issue for you? As for the change, I think it could be fixed a bit more generally by changing the |
@diosmosis We didn't roll it out on our production system, but after applying this to a test system, I wasn't able to reproduce the issue anymore. So yes, this change seems to fix the problem. By the way, it affects all data that is older than two weeks, not only what has been archived prior to the upgrade. |
That's interesting, @KaiNissen, I'm not able to reproduce this on my own. Would you be able to check in your test system if changing the |
Hi @KaiNissen @tzhelyazkova could you please check @diosmosis answer in #13315 (comment) or @diosmosis maybe you have some ideas to could get to the bottom of this issue? |
@mattab I'll create a PR w/ a test for the operator bug which we can merge in 3.6.1. If someone else reports the issue then we can debug again? |
sounds good 👍 |
Hey @mattab @diosmosis |
@tzhelyazkova could you see what |
It prints a string with the right start and end date I choose as a range period, |
@tzhelyazkova apologies for the late reply, just getting back to this. I'm not sure why this is happening, but I have a guess that it might be timezone related. Does your site in Matomo have a specific timezone? |
@tzhelyazkova any chance you could maybe reply to @diosmosis question in the last comment? |
@diosmosis @tsteur yes, our matomo is in the Europe/Berlin timezone. |
@diosmosis do you maybe have a chance to look into this again? |
Yes, I'll take a look today. |
@tzhelyazkova Well, I'm still unable to reproduce this, but if |
Hi @tzhelyazkova |
Closing since original issue is closed. |
This fixes issue #13047
The check does not take into consideration
range
period, where if you have two adjacent days, the difference is47h59m59s
and not a day.Example: If I want to get archived data from
2018-06-10
to2018-06-11
, I need to check everything between2018-06-10 00:00:00
and2018-06-11 23:59:59
. The check disregards the time part of the date.I think this bug was introduced when functions
Date::getDateStartUTC
andDate::getDateEndUTC
were deprecated. In the code they are replaced withgetTimestampUTC
which doesn't return the same format as the other two. The tests inArchiveProcessorTest
still use the deprecated functions though.p.s. Apologies for not providing unit tests for this but I couldn't set up phpunit for this project. I also realize this is not the most elegant solution but I didn't want to change too many parts of the code.