mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:39:43 +08:00
What is the problem?
When the `reporting_improvements` flag is enabled, the visits report
returns stacked chart data with separate desktop and mobile series. The
`Report` model's `valueAt` and `valueFor` methods operate directly on
`this.data`, which in stacked mode is an array of series objects (each
with a `label` and nested `data` array) rather than a flat array of `{
x, y }` points. This means the dashboard activity metrics counters
(today, yesterday, 7-day, 30-day) fail to compute correct values for the
visits report.
Additionally, the legacy warning banner in `admin-report-new.gjs`
rendered outside the `showHeader` conditional, causing it to appear even
when headers are hidden (e.g. in counters mode on the dashboard).
What is the solution?
A new `combinedData` getter on the JS `Report` model detects stacked
data (entries with a `label` property) and flattens all series into a
single array, summing `y` values for matching dates. The `valueAt` and
`valueFor` methods now use `combinedData` instead of `data` directly.
The legacy warning in `admin-report-new.gjs` is moved inside the
`showHeader` block. A system test is added to verify visit counters
display correctly with the flag both on and off.
---------
Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
7 lines
108 B
Ruby
Vendored
7 lines
108 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
Fabricator(:user_visit) do
|
|
user
|
|
visited_at Date.today
|
|
mobile false
|
|
end
|