Ignore unknown country code (#2223)

* Ignore unknown country code

* Add changelog entry
This commit is contained in:
Uku Taht 2022-09-16 11:02:39 +03:00 committed by GitHub
parent 54260c294f
commit b239f73a6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -54,6 +54,7 @@ All notable changes to this project will be documented in this file.
- Remove the `+ Add Site` link to the site-switcher dropdown in the dashboard.
- `DISABLE_REGISTRATIONS` configuration parameter can now accept `invite_only` to allow invited users to register an account while keeping regular registrations disabled plausible/analytics#1841
- New and improved Session tracking module for higher throughput and lower latency. [PR#1934](https://github.com/plausible/analytics#1934)
- Do not display ZZ country code in countries report [PR#1934](https://github.com/plausible/analytics#2223)
## v1.4.1

View File

@ -381,7 +381,7 @@ defmodule Plausible.Stats.Breakdown do
defp do_group_by(q, "visit:country") do
from(
s in q,
where: s.country_code != "\0\0",
where: s.country_code != "\0\0" and s.country_code != "ZZ",
group_by: s.country_code,
select_merge: %{country: s.country_code}
)

View File

@ -67,6 +67,14 @@ defmodule PlausibleWeb.Api.StatsController.CountriesTest do
]
end
test "ignores unknown country code ZZ", %{conn: conn, site: site} do
populate_stats(site, [build(:pageview, country_code: "ZZ")])
conn = get(conn, "/api/stats/#{site.domain}/countries?period=day")
assert json_response(conn, 200) == []
end
test "calculates conversion_rate when filtering for goal", %{conn: conn, site: site} do
populate_stats(site, [
build(:pageview,