Skip to content

Commit ad92741

Browse files
authored
Fix top pages comparison tooltip missing date labels (#6221)
* Fix top pages comparison tooltip missing date labels - The `/pages` endpoint was using `Map.merge` on a `Jason.OrderedObject`, which silently drops any merged keys during JSON encoding. Convert to a plain map first so date range labels are included in the response. * Add changelog entry * Add meta assertions to pages controller tests
1 parent 966759c commit ad92741

3 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file.
2828
- Fixed Stats API timeseries returning time buckets falling outside the queried range
2929
- Fixed issue with all non-interactive events being counted as interactive
3030
- Fixed countries map countries staying highlighted on Chrome
31+
- Fixed comparison tooltip in the top pages report missing date labels
3132

3233
## v3.2.0 - 2026-01-16
3334

lib/plausible_web/controllers/api/stats_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ defmodule PlausibleWeb.Api.StatsController do
723723
else
724724
json(conn, %{
725725
results: pages,
726-
meta: Map.merge(meta, Stats.Breakdown.formatted_date_ranges(query)),
726+
meta: Map.new(meta.values) |> Map.merge(Stats.Breakdown.formatted_date_ranges(query)),
727727
skip_imported_reason: meta[:imports_skip_reason]
728728
})
729729
end

test/plausible_web/controllers/api/stats_controller/pages_test.exs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,8 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
657657
"percentage" => 100.0
658658
}
659659
]
660+
661+
assert json_response(conn, 200)["meta"] == %{"date_range_label" => "1 Jan 2021"}
660662
end
661663

662664
test "returns top pages with :not_member filter on custom pageview props including (none) value",
@@ -2212,6 +2214,11 @@ defmodule PlausibleWeb.Api.StatsController.PagesTest do
22122214
}
22132215
}
22142216
]
2217+
2218+
assert json_response(conn, 200)["meta"] == %{
2219+
"date_range_label" => "2 Jan 2021",
2220+
"comparison_date_range_label" => "1 Jan 2021"
2221+
}
22152222
end
22162223

22172224
on_ee do

0 commit comments

Comments
 (0)