Skip to content
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

Report date to load by default doesn't work #7795

Closed
ohaucke opened this issue Apr 30, 2015 · 11 comments
Closed

Report date to load by default doesn't work #7795

ohaucke opened this issue Apr 30, 2015 · 11 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@ohaucke
Copy link

ohaucke commented Apr 30, 2015

If i set "Report date to load by default" to "Current Month" and go back to the dashboard it shows me the report for today.

Reproduce:

  1. $User->Settings: Report date to load by default: Current Month
  2. Open a new Tab/Browserwindow with the domain (e.g. http://piwik.domain.com)

Version: 2.13.0.

@mattab
Copy link
Member

mattab commented Apr 30, 2015

Hi @ohaucke
Thanks for the report!
Unfortunately the feature is indeed broken....
We will fix it in the next release (in few days or weeks)

@mattab mattab added this to the 2.13.1 milestone Apr 30, 2015
@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Apr 30, 2015
@diosmosis diosmosis self-assigned this Apr 30, 2015
@mnapoli
Copy link
Contributor

mnapoli commented Apr 30, 2015

Works for me. There's one thing that has changed regarding that so may be related: #7623

@diosmosis
Copy link
Member

I can reproduce, you have to visit piwik in a new tab.

@diosmosis
Copy link
Member

The cause of the bug is here: https://github.com/piwik/piwik/blob/master/plugins/UsersManager/UserPreferences.php#L107

getDefaultDateWithoutValidation() sets the default value for the user preference to 'today'. It is then passed to getDefaultPeriodWithoutValidation(), which will set the period to 'day' w/o ever looking at the user preference. The quick fix would be to move the getDefaultPeriodWithoutValidation() call to before the getDefaultDateWithoutValidation(), however the code is confusing and there is no complete specification about how this feature is meant to behave, so I can't be sure it won't have side effects.

@mnapoli You've recently worked w/ this code, do you have any insights?

@diosmosis diosmosis removed their assignment Apr 30, 2015
@mattab
Copy link
Member

mattab commented May 1, 2015

How to reproduce:

  • Set date by default to "Current month"
  • Click on Piwik icon:
  • Got: it loads current day period=day
  • Expected: it loads current month period=month

Also

  • check all other combinations of dates to load by default, in the UI, are working too
  • let's write a test for this feature so it won't regress in the future (and I feel sorry
    for having written this messy code months ago and not having written tests for it!)

@mnapoli
Copy link
Contributor

mnapoli commented May 1, 2015

@benaka sorry I don't have an idea on the top of my head (can't look in details right now), I agree the code is really confusing and when I worked on that I didn't improve it much (probably not even at all) as the better solution we identified had a too high refactoring cost.

@diosmosis
Copy link
Member

@mnapoli Do you remember what the better solution was?

@mnapoli
Copy link
Contributor

mnapoli commented May 1, 2015

@diosmosis not in details right now, we discussed it with @mattab. It involved handling period + date as a single entity (e.g. wrap them in a single concept/object), allowing for example to validate them both (e.g. this change is kinda in that spirit). Because some dates only make sense for some ranges, and some ranges only make sense for some dates, they are highly coupled. But needless to say it's a big change…

@diosmosis
Copy link
Member

Centralizing the query parameter logic in classes sounds like a good idea. Will be simple w/ DI.

@mnapoli mnapoli self-assigned this May 2, 2015
mnapoli added a commit that referenced this issue May 3, 2015
@mnapoli
Copy link
Contributor

mnapoli commented May 3, 2015

PR: #7814

@diosmosis
Copy link
Member

Fixed by #7814

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

4 participants