mirror of
https://github.com/plausible/analytics.git
synced 2024-11-29 14:04:12 +03:00
WIP
This commit is contained in:
parent
1a9f614c41
commit
3202bf2fe9
BIN
city_database.mmdb
Normal file
BIN
city_database.mmdb
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 MiB |
@ -19,9 +19,11 @@ defmodule Plausible.Stats.FilterSuggestions do
|
||||
|> Enum.filter(fn c -> Enum.find(matches, false, fn x -> x == c end) end)
|
||||
|> Enum.slice(0..24)
|
||||
|> Enum.map(fn c ->
|
||||
info = ISOCodes.ISO3166_1.get(c)
|
||||
|
||||
%{
|
||||
code: CountryName.to_alpha3(c),
|
||||
name: CountryName.from_iso3166(c)
|
||||
code: (info && info.alpha_3) || c,
|
||||
name: (info && info.name) || c
|
||||
}
|
||||
end)
|
||||
end
|
||||
@ -37,9 +39,11 @@ defmodule Plausible.Stats.FilterSuggestions do
|
||||
)
|
||||
|> ClickhouseRepo.all()
|
||||
|> Enum.map(fn c ->
|
||||
info = ISOCodes.ISO3166_2.get(c)
|
||||
|
||||
%{
|
||||
code: c,
|
||||
name: CountryName.from_iso3166_2(c)
|
||||
name: (info && info.name) || c
|
||||
}
|
||||
end)
|
||||
end
|
||||
|
@ -445,7 +445,7 @@ defmodule PlausibleWeb.Api.StatsController do
|
||||
countries =
|
||||
Stats.breakdown(site, query, "visit:country", ["visitors"], pagination)
|
||||
|> maybe_add_cr(site, query, {300, 1}, "country", "visit:country")
|
||||
|> transform_keys(%{"country" => "name"})
|
||||
|> transform_keys(%{"country" => "alpha_2", "visitors" => "count"})
|
||||
|> add_percentages
|
||||
|
||||
if params["csv"] do
|
||||
@ -458,8 +458,9 @@ defmodule PlausibleWeb.Api.StatsController do
|
||||
else
|
||||
countries =
|
||||
Enum.map(countries, fn country ->
|
||||
alpha3 = Stats.CountryName.to_alpha3(country["name"])
|
||||
Map.put(country, "name", alpha3)
|
||||
info = ISOCodes.ISO3166_1.get(country["alpha_2"])
|
||||
alpha_3 = if info, do: info.alpha_3, else: country["alpha_2"]
|
||||
Map.put(country, "name", alpha_3)
|
||||
end)
|
||||
|
||||
json(conn, countries)
|
||||
|
3
mix.exs
3
mix.exs
@ -93,7 +93,8 @@ defmodule Plausible.MixProject do
|
||||
{:envy, "~> 1.1.1"},
|
||||
{:phoenix_pagination, "~> 0.7.0"},
|
||||
{:hammer, "~> 6.0"},
|
||||
{:public_suffix, git: "https://github.com/axelson/publicsuffix-elixir"}
|
||||
{:public_suffix, git: "https://github.com/axelson/publicsuffix-elixir"},
|
||||
{:iso_codes, "~> 0.1"}
|
||||
]
|
||||
end
|
||||
|
||||
|
1
mix.lock
1
mix.lock
@ -42,6 +42,7 @@
|
||||
"httpoison": {:hex, :httpoison, "1.8.0", "6b85dea15820b7804ef607ff78406ab449dd78bed923a49c7160e1886e987a3d", [:mix], [{:hackney, "~> 1.17", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "28089eaa98cf90c66265b6b5ad87c59a3729bea2e74e9d08f9b51eb9729b3c3a"},
|
||||
"hut": {:hex, :hut, "1.3.0", "71f2f054e657c03f959cf1acc43f436ea87580696528ca2a55c8afb1b06c85e7", [:"erlang.mk", :rebar, :rebar3], [], "hexpm", "7e15d28555d8a1f2b5a3a931ec120af0753e4853a4c66053db354f35bf9ab563"},
|
||||
"idna": {:hex, :idna, "6.1.1", "8a63070e9f7d0c62eb9d9fcb360a7de382448200fbbd1b106cc96d3d8099df8d", [:rebar3], [{:unicode_util_compat, "~>0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "92376eb7894412ed19ac475e4a86f7b413c1b9fbb5bd16dccd57934157944cea"},
|
||||
"iso_codes": {:hex, :iso_codes, "0.1.0", "bae2c192b43b2130bef87f684ec38e09d5dc16ff07aff13d3624d576e75443d7", [:mix], [{:gettext, "~> 0.18.2", [hex: :gettext, repo: "hexpm", optional: false]}, {:jason, "~> 1.2.2", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "af4f6042f5e84571ee61faa9ca46c550811559a7badf28568d0bb3ea36237e51"},
|
||||
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
|
||||
"jumper": {:hex, :jumper, "1.0.1", "3c00542ef1a83532b72269fab9f0f0c82bf23a35e27d278bfd9ed0865cecabff", [:mix], [], "hexpm", "318c59078ac220e966d27af3646026db9b5a5e6703cb2aa3e26bcfaba65b7433"},
|
||||
"kaffy": {:hex, :kaffy, "0.9.0", "bef34c9729f6a3af4d0dea8eede8bcb9e11371a83ac9a8b393991bce81839517", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.11", [hex: :phoenix_html, repo: "hexpm", optional: false]}], "hexpm", "d18ff57b8e68feb433aed11e71510cd357abc7034e75358af5deff7d0d4c6ed3"},
|
||||
|
Loading…
Reference in New Issue
Block a user