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

By default select site creation date if site was created today or if select date is before site creation date #16287

Merged
merged 4 commits into from Aug 24, 2020

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Aug 11, 2020

fix #13754

implementing this already now as we'll want to patch this on the cloud

@tsteur tsteur added Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. labels Aug 11, 2020
@tsteur tsteur added this to the 4.0.0 RC milestone Aug 11, 2020
@dev-clavis
Copy link

dev-clavis commented Aug 12, 2020

Could it be that the Menu test fails because the period is week and for week it shouldn't matter if the day is previous creation date because the date is within the same week?

'idSite' => 1, 'period' => 'week', -'date' => '2020-08-08', +'date' => '2020-08-07',
https://travis-ci.org/github/matomo-org/matomo/jobs/717098658#L736

// date is before site creation date but it is the current week so no need to change it $default = $this->menu->urlForDefaultUserParams($this->idSiteToday, 'week', '2020-08-06'); $this->assertEquals([ 'idSite' => $this->idSiteToday, 'period' => 'week', 'date' => '2020-08-06', ], $default);
I don't know if period range includes week
if ($defaultPeriod !== 'range' && !empty($defaultDate) && $defaultDate !== 'today') {

@tsteur
Copy link
Member Author

tsteur commented Aug 12, 2020

@dev-clavis I'll have a look when I continue working on this but basically added some code so the week should work as expected which is needed when someone manually sets a very old date. I simply haven't adjusted the expected test result yet I think.

@tsteur tsteur added Needs Review PRs that need a code review and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. labels Aug 12, 2020
@tsteur
Copy link
Member Author

tsteur commented Aug 12, 2020

Tests should pass now. There is one test failure and one UI failure in https://builds-artifacts.matomo.org/matomo-org/matomo/4.x-dev/41910/ but seems unrelated to this change.

if (!$endDate->isLater($siteCreationDate)) {
// when selected date is before site creation date or it is the site creation day
$defaultDate = $siteCreationDate->toString();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets the date to load to the site creation date if the default period end date is past the site creation date correct? So if the site creation date is 2015-02-02, and $defaultDate is 2020-01-01 w/ period = year, then the date is always set to 2015-02-02. Is this the intended functionality? It doesn't sound like what the PR title implies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 adjusted the PR title @diosmosis

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then should it be $endDate->isEarlier($siteCreationDate)? To set it "if select date is before site creation date"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's pretty much the same or not? !$endDate->isLater == $endDate->isEarlier()? Will change the code ... tests still pass that way

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, I missed the ! while reading, LGTM

@tsteur tsteur changed the title Set default date to site creation date if site was created basically today By default select site creation date if site was created today or if select date is before site creation date Aug 23, 2020
@tsteur tsteur merged commit 1001cd2 into 4.x-dev Aug 24, 2020
@tsteur tsteur deleted the defaultdateupdate branch August 24, 2020 02:12
@mattab mattab modified the milestones: 4.0.0-RC, 4.0.0 Sep 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When looking at Yesterday's data, and there is data for today, notify users to try to look at Today
4 participants