analytics/lib/workers/locations_sync.ex
Karl-Aksel Puulmann ee3d1e770e
APIv2: visit:country_name, visit:region_name, visit:city_name dimensions (#4328)
* Add data migration for creating and syncing location_data table and dictionary

* Migration to populate location data

* Daily cron to refresh location dataset if changed

* Add support for visit:country_name, visit:region_name and visit:city_name dimensions

Under the hood this relies on a `location_data` table in clickhouse being regularly synced with
plausible/location repo and dictionary lookups used in ALIAS columns

* Update queue name

* Update documentation

* Explicit structs

* Improve docs further

* Migration comment

* Add queues

* Add error when already loaded

* Test for filtering by new dimensions

* Update deps

* dimension -> select_dimension

* Update a test
2024-08-13 09:44:58 +03:00

16 lines
312 B
Elixir

defmodule Plausible.Workers.LocationsSync do
@moduledoc false
use Plausible.Repo
use Oban.Worker, queue: :locations_sync
@impl Oban.Worker
def perform(_job) do
if Plausible.DataMigration.LocationsSync.out_of_date?() do
Plausible.DataMigration.LocationsSync.run()
end
:ok
end
end