From 950bd012d54651e2a837b9bb4c728b179a5eb17b Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Mon, 18 Oct 2021 15:49:55 +0200 Subject: [PATCH] Simplify geolix database config --- config/runtime.exs | 3 ++- lib/plausible_web/controllers/api/external_controller.ex | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/runtime.exs b/config/runtime.exs index 72a208bac..f31c2bc41 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -386,7 +386,8 @@ if config_env() != :test && geolite2_country_db do %{ id: :country, adapter: Geolix.Adapter.MMDB2, - source: geolite2_country_db + source: geolite2_country_db, + result_as: :raw } ] end diff --git a/lib/plausible_web/controllers/api/external_controller.ex b/lib/plausible_web/controllers/api/external_controller.ex index 26ec39cc5..900bad93b 100644 --- a/lib/plausible_web/controllers/api/external_controller.ex +++ b/lib/plausible_web/controllers/api/external_controller.ex @@ -194,9 +194,7 @@ defmodule PlausibleWeb.Api.ExternalController do PlausibleWeb.RemoteIp.get(conn) |> Geolix.lookup() - if result && result[:country] && result[:country].country do - result[:country].country.iso_code - end + get_in(result, [:country, :country, :iso_code]) end defp parse_referrer(_, nil), do: nil