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

Limit date ranges that end far in the future #22592

Open
wants to merge 1 commit into
base: 5.x-dev
Choose a base branch
from

Conversation

sgiehl
Copy link
Member

@sgiehl sgiehl commented Sep 16, 2024

Description:

Matomo currently only restricts provided dates in the past. A date currently can't be set to earlier than August 1991 - the date were the first website went live.

Future dates are currently not restricted, even though it doesn't make sense to provide dates that are far in the future. As Matomo won't archive future dates, there can't be any data returned anyway.

Providing single periods like day, week, month or year far in the future is unproblematic, as Matomo would simply display no data for it.

Range periods and multiple period requests however are a bit different, as Matomo would try to process all subperiods that are included. As dates in the future can't have any data anyway, there is not much value in even trying to process those dates unlimited.
Therefor this PR introduces an internal limit for range periods. If a range is provided with an end date that is more than 10 years in the future, Matomo will automatically cut down the range to end at end of the current year + 10 years.

Review

@sgiehl sgiehl added c: Usability For issues that let users achieve a defined goal more effectively or efficiently. c: Dates & Calendar For bugs and features in date range selections, calendar UI, and report frequency. labels Sep 16, 2024
@sgiehl sgiehl added this to the 5.2.0 milestone Sep 16, 2024
@sgiehl sgiehl force-pushed the disallowfuturedates branch 2 times, most recently from 007a431 to a72d66c Compare September 16, 2024 16:41
@sgiehl sgiehl changed the title Improve handling of provided dates that are far in the future Limit date ranges that end far in the future Sep 18, 2024
@sgiehl sgiehl marked this pull request as ready for review September 18, 2024 15:14
@sgiehl sgiehl added the Needs Review PRs that need a code review label Sep 18, 2024
@sgiehl sgiehl requested a review from a team September 18, 2024 15:28
*
* @return int
*/
public static function getMaxAllowedEndTimestamp(): int
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the method need to be public if not used elsewhere?

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 doesn't and it might not even need to be static. But this new "Limit" is supposed to be something global for ranges. So it imho should be reusable if needed anywhere else.
We could actually even consider to mark this method as @api, so it will be shown in the documentation 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, ok, well if we want to have it in the API scope, then yeah, keep it public. With the static vs dynamic, it seemed to me we prefer dynamic in a lot of places, even just to get a single thing we instantiate a class.. so I could see that used here as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Dates & Calendar For bugs and features in date range selections, calendar UI, and report frequency. c: Usability For issues that let users achieve a defined goal more effectively or efficiently. Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants