From b4def254dc489c532999f75bddb82d2a1aa05dbc Mon Sep 17 00:00:00 2001 From: Vincent Degove Date: Tue, 12 Nov 2024 11:32:22 +0100 Subject: [PATCH] =?UTF-8?q?MAJ=20donn=C3=A9es=20g=C3=A9ographiques=202024?= =?UTF-8?q?=20(#4291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Communes script: 2024 * update departements 2024 * Update 2024 EPCI * Move disabling DB logs from dev to dev.secret.template --- .../lib/mix/tasks/transport/import_communes.ex | 15 +++++++++++++-- .../mix/tasks/transport/import_departements.ex | 4 ++-- .../lib/mix/tasks/transport/import_epci.ex | 4 ++-- config/dev.exs | 3 --- config/dev.secret.template.exs | 3 +++ 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/apps/transport/lib/mix/tasks/transport/import_communes.ex b/apps/transport/lib/mix/tasks/transport/import_communes.ex index c7dc73e479..c1e859fedf 100644 --- a/apps/transport/lib/mix/tasks/transport/import_communes.ex +++ b/apps/transport/lib/mix/tasks/transport/import_communes.ex @@ -11,10 +11,10 @@ defmodule Mix.Tasks.Transport.ImportCommunes do require Logger # List of communes with their geometry, but lacking additional information - @communes_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/communes-100m.geojson" + @communes_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/communes-100m.geojson" # List of official communes with additional information (population, arrondissement, etc.) # See https://github.com/etalab/decoupage-administratif - @communes_url "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/communes.json" + @communes_url "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/communes.json" @doc "Loads regions from the database and returns a list of tuples with INSEE code and id" def regions_by_insee do @@ -86,6 +86,17 @@ defmodule Mix.Tasks.Transport.ImportCommunes do changeset_change_keys end + # See https://github.com/datagouv/decoupage-administratif/issues/49 for the 3 communes below + # Population taken on Wikipedia, 2021 + def insert_or_update_commune(%{"code" => "60694", "nom" => "Les Hauts-Talican"} = params, regions, geojsons), + do: insert_or_update_commune(params |> Map.put("population", 543), regions, geojsons) + + def insert_or_update_commune(%{"code" => "85165", "nom" => "L'Oie"} = params, regions, geojsons), + do: insert_or_update_commune(params |> Map.put("population", 1259), regions, geojsons) + + def insert_or_update_commune(%{"code" => "85212", "nom" => "Sainte-Florence"} = params, regions, geojsons), + do: insert_or_update_commune(params |> Map.put("population", 1333), regions, geojsons) + defp get_or_create_commune(insee) do Commune |> Repo.get_by(insee: insee) diff --git a/apps/transport/lib/mix/tasks/transport/import_departements.ex b/apps/transport/lib/mix/tasks/transport/import_departements.ex index 4fb76a4da7..e19004fa95 100644 --- a/apps/transport/lib/mix/tasks/transport/import_departements.ex +++ b/apps/transport/lib/mix/tasks/transport/import_departements.ex @@ -8,9 +8,9 @@ defmodule Mix.Tasks.Transport.ImportDepartements do alias DB.{Departement, Repo} require Logger - @departements_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/departements-100m.geojson" + @departements_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/departements-100m.geojson" # See https://github.com/etalab/decoupage-administratif - @departements_url "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/departements.json" + @departements_url "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/departements.json" def insert_or_update_departement( %{ diff --git a/apps/transport/lib/mix/tasks/transport/import_epci.ex b/apps/transport/lib/mix/tasks/transport/import_epci.ex index 77595efb4a..6358a1b4b9 100644 --- a/apps/transport/lib/mix/tasks/transport/import_epci.ex +++ b/apps/transport/lib/mix/tasks/transport/import_epci.ex @@ -10,8 +10,8 @@ defmodule Mix.Tasks.Transport.ImportEPCI do alias DB.{Commune, EPCI, Repo} require Logger - @epci_file "https://unpkg.com/@etalab/decoupage-administratif@3.1.1/data/epci.json" - @epci_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2023/geojson/epci-100m.geojson" + @epci_file "https://unpkg.com/@etalab/decoupage-administratif@4.0.0/data/epci.json" + @epci_geojson_url "http://etalab-datasets.geo.data.gouv.fr/contours-administratifs/2024/geojson/epci-100m.geojson" def run(_params) do Logger.info("Importing EPCIs") diff --git a/config/dev.exs b/config/dev.exs index b934c6d6f9..8b94631bdf 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -83,9 +83,6 @@ config :oauth2, Datagouvfr.Authentication, # Add a dev.secret.exs to use a real email provider config :transport, Transport.Mailer, adapter: Swoosh.Adapters.Local -# Uncomment if you want to disable all logs from the database -# config :transport, DB.Repo, log: false - extra_config_file = Path.join(__DIR__, "#{config_env()}.secret.exs") if File.exists?(extra_config_file) do diff --git a/config/dev.secret.template.exs b/config/dev.secret.template.exs index efd369f623..27d1ec5242 100644 --- a/config/dev.secret.template.exs +++ b/config/dev.secret.template.exs @@ -38,3 +38,6 @@ config :ex_aws, host: "127.0.0.1", port: 9000 ] + +# Uncomment if you want to disable all logs from the database +# config :transport, DB.Repo, log: false