Skip to content

Commit bd2b9a2

Browse files
committed
partial time labels to empty list
1 parent 44f64ad commit bd2b9a2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/plausible/stats/time.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ defmodule Plausible.Stats.Time do
131131
partial_labels(time_labels, date_range, &Date.beginning_of_month/1, &Date.end_of_month/1)
132132

133133
_ ->
134-
nil
134+
[]
135135
end
136136
end
137137

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,22 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest do
15001500
assert response["meta"]["partial_time_labels"] == []
15011501
end
15021502

1503+
test "partial_time_labels is an empty list when interval is not week nor month", %{
1504+
conn: conn,
1505+
site: site
1506+
} do
1507+
response =
1508+
do_query(conn, site, %{
1509+
"date_range" => "28d",
1510+
"metrics" => ["visitors"],
1511+
"dimensions" => ["time:day"],
1512+
"include" => %{"time_labels" => true, "partial_time_labels" => true}
1513+
})
1514+
1515+
assert length(response["meta"]["time_labels"]) == 28
1516+
assert response["meta"]["partial_time_labels"] == []
1517+
end
1518+
15031519
test "returns stats for a day with a minute interval", %{conn: conn, site: site} do
15041520
populate_stats(site, [
15051521
build(:pageview, timestamp: ~N[2023-03-01 12:00:00])

0 commit comments

Comments
 (0)