mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-18 22:29:29 +08:00
Makes the redesigned dashboard Site traffic section real for the core
traffic summary.
- In scope: live pageview headline, comparison trend, logged-in share
KPI, and stacked traffic chart.
- Out of scope: top referrers, top countries, and narrative traffic
insights. Those remain placeholder UI for a follow-up.
- Reuses the existing report stacked chart for both the dashboard
section and `/admin/reports/site_traffic`.
- Extends the existing site traffic report data contract instead of
introducing a dashboard-only chart shape.
- Keeps traffic aggregation, KPI calculation, and trend eligibility on
the backend.
- Supports dashboard preset and custom date ranges with inclusive date
windows.
- Ships traffic data in this section payload shape:
```json
{
"id": "traffic",
"data": {
"kpis": {
"browser_pageviews": {
"value": 30,
"percent_change": 900,
"comparison_period": {
"start_date": "2026-04-28",
"end_date": "2026-04-30"
}
},
"logged_in_share": {
"value": 33
}
},
"pageview_series": [
{
"req": "page_view_logged_in_browser",
"label": "Logged in",
"color": "#4B3CE0",
"data": [
{ "x": "2026-05-01", "y": 10 }
]
}
]
}
}
```
49 lines
1.6 KiB
Ruby
Vendored
49 lines
1.6 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
Fabricator(:application_request) do
|
|
transient request_type: :page_view_logged_in_browser
|
|
|
|
date { Date.current }
|
|
count 1
|
|
req_type { |transients| ApplicationRequest.req_types.fetch(transients[:request_type].to_s) }
|
|
end
|
|
|
|
Fabricator(:logged_in_application_request, from: :application_request) do
|
|
transient request_type: :page_view_logged_in
|
|
end
|
|
|
|
Fabricator(:anonymous_application_request, from: :application_request) do
|
|
transient request_type: :page_view_anon
|
|
end
|
|
|
|
Fabricator(:logged_in_browser_application_request, from: :application_request) do
|
|
transient request_type: :page_view_logged_in_browser
|
|
end
|
|
|
|
Fabricator(:logged_in_browser_mobile_application_request, from: :application_request) do
|
|
transient request_type: :page_view_logged_in_browser_mobile
|
|
end
|
|
|
|
Fabricator(:logged_in_browser_beacon_application_request, from: :application_request) do
|
|
transient request_type: :page_view_logged_in_browser_beacon
|
|
end
|
|
|
|
Fabricator(:anonymous_browser_application_request, from: :application_request) do
|
|
transient request_type: :page_view_anon_browser
|
|
end
|
|
|
|
Fabricator(:anonymous_browser_mobile_application_request, from: :application_request) do
|
|
transient request_type: :page_view_anon_browser_mobile
|
|
end
|
|
|
|
Fabricator(:anonymous_browser_beacon_application_request, from: :application_request) do
|
|
transient request_type: :page_view_anon_browser_beacon
|
|
end
|
|
|
|
Fabricator(:embedded_application_request, from: :application_request) do
|
|
transient request_type: :page_view_embed
|
|
end
|
|
|
|
Fabricator(:crawler_application_request, from: :application_request) do
|
|
transient request_type: :page_view_crawler
|
|
end
|