Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
return city codes as integers in suggestions (#4589)
RobertJoonas45c0d538daa0
diff --git a/lib/plausible/stats/filter_suggestions.ex b/lib/plausible/stats/filter_suggestions.exindex b9d9c32541..53faa05c1c 100644--- a/lib/plausible/stats/filter_suggestions.ex+++ b/lib/plausible/stats/filter_suggestions.ex@@ -119,7 +119,7 @@ defmodule Plausible.Stats.FilterSuggestions docity = Location.get_city(c)%{- value: Integer.to_string(c),+ value: c,label: (city && city.name) || "N/A"}end)@@ -145,12 +145,7 @@ defmodule Plausible.Stats.FilterSuggestions docity && String.contains?(String.downcase(city.name), filter_search)end)|> Enum.slice(0..24)- |> Enum.map(fn c ->- %{- value: Integer.to_string(c.id),- label: c.name- }- end)+ |> Enum.map(fn c -> %{value: c.id, label: c.name} end)enddef filter_suggestions(site, _query, "goal", filter_search) dodiff --git a/test/plausible_web/controllers/api/stats_controller/suggestions_test.exs b/test/plausible_web/controllers/api/stats_controller/suggestions_test.exsindex ab8530dcfd..da751a90bb 100644--- a/test/plausible_web/controllers/api/stats_controller/suggestions_test.exs+++ b/test/plausible_web/controllers/api/stats_controller/suggestions_test.exs@@ -131,7 +131,7 @@ defmodule PlausibleWeb.Api.StatsController.SuggestionsTest do"/api/stats/#{site.domain}/suggestions/city?q=Kär")- assert json_response(conn, 200) == [%{"value" => "591632", "label" => "Kärdla"}]+ assert json_response(conn, 200) == [%{"value" => 591_632, "label" => "Kärdla"}]endtest "returns suggestions for countries without country in search", %{conn: conn, site: site} do@@ -883,8 +883,8 @@ defmodule PlausibleWeb.Api.StatsController.SuggestionsTest do)assert json_response(conn, 200) == [- %{"value" => "588409", "label" => "Tallinn"},- %{"value" => "591632", "label" => "Kärdla"}+ %{"value" => 588_409, "label" => "Tallinn"},+ %{"value" => 591_632, "label" => "Kärdla"}]endend@@ -912,7 +912,7 @@ defmodule PlausibleWeb.Api.StatsController.SuggestionsTest do"/api/stats/#{site.domain}/suggestions/city?filters=#{filters}&q=&with_imported=true")- assert json_response(conn, 200) == [%{"value" => "591632", "label" => "Kärdla"}]+ assert json_response(conn, 200) == [%{"value" => 591_632, "label" => "Kärdla"}]endtest "queries imported cities when filtering by city", %{@@ -932,7 +932,7 @@ defmodule PlausibleWeb.Api.StatsController.SuggestionsTest do"/api/stats/#{site.domain}/suggestions/city?period=month&date=2019-01-01&filters=#{filters}&q=&with_imported=true")- assert json_response(conn, 200) == [%{"value" => "591632", "label" => "Kärdla"}]+ assert json_response(conn, 200) == [%{"value" => 591_632, "label" => "Kärdla"}]endtest "ignores imported city data when not requested", %{