Skip to content

Fix annotation icon placement for "lastX"/"previousX" ranges #21862

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

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

mneudert
Copy link
Member

@mneudert mneudert commented Jan 31, 2024

Description:

When viewing an evolution graph, existing annotations are fetched using Annotations\Controller::getAnnotationCountForDates(), internal API call is using Annotations\API::getAnnotationCountForDates, to display as icons below the graph:

If your current user is viewing reports using either previous30 or last30 ranges (can be set in "Personal Settings"), the annotation icons are misplaced by one day:

This happens because of the special treatment of the aforementioned ranges in Annotations::getDateRangeForPeriod(). Availalbe dates for annotations are using Date::factory('now'), internally only using subPeriod() in this case, not discarding the current time information.

Later in the process, during Annotations\AnnotationsList::search(), a timestamp comparison is used to select the day an annotation is displayed for. As all annotations are stored without any time information, 2024-01-02 with be matched by, for example, the incorrect 2024-01-01 12:00:00 < 2024-01-02 11:59:59 range, instead of next days 2024-01-02 00:00:00 < 2024-01-02 23:59:59 range, and then displayed at the wrong position.

Discarding the time information after range parsing should fix that problem.

Fixes #21837

Review

@mneudert mneudert changed the base branch from 5.x-dev to 5.0.x-dev January 31, 2024 13:34
@mneudert mneudert marked this pull request as ready for review January 31, 2024 14:05
@mneudert mneudert added Bug For errors / faults / flaws / inconsistencies etc. not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. c: Design / UI For issues that impact Matomo's user interface or the design overall. Needs Review PRs that need a code review labels Jan 31, 2024
@mneudert mneudert requested a review from a team January 31, 2024 14:05
@mneudert mneudert linked an issue Jan 31, 2024 that may be closed by this pull request
@mneudert mneudert added this to the 5.0.2 milestone Jan 31, 2024
Copy link
Member

@sgiehl sgiehl left a comment

Choose a reason for hiding this comment

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

Nice find. Tested locally. I can confirm that this fixes the issue 👍

@sgiehl sgiehl merged commit e540059 into 5.0.x-dev Jan 31, 2024
@sgiehl sgiehl deleted the m21837 branch January 31, 2024 16:05
sgiehl pushed a commit that referenced this pull request Feb 5, 2024
* Add tests for Annotations API with "last30" range

* Fix annotation icon placement for "lastX"/"previousX" ranges
sgiehl added a commit that referenced this pull request Feb 5, 2024
…#21880)

* Add tests for Annotations API with "last30" range

* Fix annotation icon placement for "lastX"/"previousX" ranges

Co-authored-by: Marc Neudert <marc@innocraft.com>
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. c: Design / UI For issues that impact Matomo's user interface or the design overall. 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.
Development

Successfully merging this pull request may close these issues.

[Bug] Annotations get wrong date on timeline chart view
2 participants