diff --git a/apps/transport/lib/transport_web/views/dataset_view.ex b/apps/transport/lib/transport_web/views/dataset_view.ex
index ecf07a04db..54919eee7f 100644
--- a/apps/transport/lib/transport_web/views/dataset_view.ex
+++ b/apps/transport/lib/transport_web/views/dataset_view.ex
@@ -367,12 +367,6 @@ defmodule TransportWeb.DatasetView do
|> Enum.filter(&Resource.documentation?/1)
end
- def real_time_public_transit?(%Dataset{type: "public-transit"} = dataset) do
- not Enum.empty?(real_time_official_resources(dataset))
- end
-
- def real_time_public_transit?(%Dataset{}), do: false
-
def community_resources(dataset), do: Dataset.community_resources(dataset)
def licence_url(licence) when licence in ["fr-lo", "lov2"],
@@ -426,7 +420,7 @@ defmodule TransportWeb.DatasetView do
resources
|> Enum.filter(fn r -> r.format == "csv" end)
|> Enum.reject(fn r -> Resource.community_resource?(r) or Resource.documentation?(r) end)
- |> Enum.max_by(& &1.last_update, DateTime, fn -> nil end)
+ |> Enum.max_by(&{&1.type, &1.last_update}, TransportWeb.DatasetView.ResourceTypeSortKey, fn -> nil end)
end
def get_resource_to_display(%Dataset{type: type, resources: resources})
@@ -585,3 +579,13 @@ defmodule TransportWeb.DatasetView do
"fa fa-heart #{value}" |> String.trim()
end
end
+
+defmodule TransportWeb.DatasetView.ResourceTypeSortKey do
+ def compare({left_type, left_last_update}, {right_type, right_last_update}) do
+ cond do
+ left_type == right_type -> DateTime.compare(left_last_update, right_last_update)
+ left_type == "main" -> :gt
+ true -> :lt
+ end
+ end
+end
diff --git a/apps/transport/lib/validators/validator_selection.ex b/apps/transport/lib/validators/validator_selection.ex
index a5ffd7fc6b..b786fd9c1e 100644
--- a/apps/transport/lib/validators/validator_selection.ex
+++ b/apps/transport/lib/validators/validator_selection.ex
@@ -33,7 +33,14 @@ defmodule Transport.ValidatorsSelection.Impl do
def validators(%{format: "GTFS"}), do: [Validators.GTFSTransport]
def validators(%{format: "gtfs-rt"}), do: [Validators.GTFSRT]
def validators(%{format: "gbfs"}), do: [Validators.GBFSValidator]
- def validators(%{format: "NeTEx"}), do: [Validators.NeTEx]
+
+ def validators(%{format: "NeTEx"}) do
+ if netex_validator_enabled?() do
+ [Validators.NeTEx]
+ else
+ []
+ end
+ end
def validators(%{schema_name: schema_name}) when not is_nil(schema_name) do
cond do
@@ -49,4 +56,6 @@ defmodule Transport.ValidatorsSelection.Impl do
end
def validators(_), do: []
+
+ defp netex_validator_enabled?, do: !Application.fetch_env!(:transport, :disable_netex_validator)
end
diff --git a/apps/transport/priv/gettext/alert.pot b/apps/transport/priv/gettext/alert.pot
index 6d63c9f33e..bb5c2fb819 100644
--- a/apps/transport/priv/gettext/alert.pot
+++ b/apps/transport/priv/gettext/alert.pot
@@ -29,7 +29,3 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Unable to get this dataset for the moment"
msgstr ""
-
-#, elixir-autogen, elixir-format
-msgid "This feature is currently not available."
-msgstr ""
diff --git a/apps/transport/priv/gettext/db-dataset.pot b/apps/transport/priv/gettext/db-dataset.pot
index 5fbb0754fc..38a0347f40 100644
--- a/apps/transport/priv/gettext/db-dataset.pot
+++ b/apps/transport/priv/gettext/db-dataset.pot
@@ -75,7 +75,7 @@ msgid "Charging & refuelling stations"
msgstr ""
#, elixir-autogen, elixir-format
-msgid "Public transit - static schedules"
+msgid "Public transit"
msgstr ""
#, elixir-autogen, elixir-format
diff --git a/apps/transport/priv/gettext/en/LC_MESSAGES/alert.po b/apps/transport/priv/gettext/en/LC_MESSAGES/alert.po
index 7d7f0874ab..aacda5c257 100644
--- a/apps/transport/priv/gettext/en/LC_MESSAGES/alert.po
+++ b/apps/transport/priv/gettext/en/LC_MESSAGES/alert.po
@@ -29,7 +29,3 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Unable to get this dataset for the moment"
msgstr ""
-
-#, elixir-autogen, elixir-format
-msgid "This feature is currently not available."
-msgstr ""
diff --git a/apps/transport/priv/gettext/en/LC_MESSAGES/db-dataset.po b/apps/transport/priv/gettext/en/LC_MESSAGES/db-dataset.po
index fe4d7b66cc..4e092e1180 100644
--- a/apps/transport/priv/gettext/en/LC_MESSAGES/db-dataset.po
+++ b/apps/transport/priv/gettext/en/LC_MESSAGES/db-dataset.po
@@ -76,7 +76,7 @@ msgid "Charging & refuelling stations"
msgstr ""
#, elixir-autogen, elixir-format, fuzzy
-msgid "Public transit - static schedules"
+msgid "Public transit"
msgstr ""
#, elixir-autogen, elixir-format
diff --git a/apps/transport/priv/gettext/fr/LC_MESSAGES/alert.po b/apps/transport/priv/gettext/fr/LC_MESSAGES/alert.po
index fef9ff23a2..c704b97474 100644
--- a/apps/transport/priv/gettext/fr/LC_MESSAGES/alert.po
+++ b/apps/transport/priv/gettext/fr/LC_MESSAGES/alert.po
@@ -29,7 +29,3 @@ msgstr "Une erreur a eu lieu lors de la récupération de vos ressources"
#, elixir-autogen, elixir-format
msgid "Unable to get this dataset for the moment"
msgstr "Impossible de récupérer ce jeu de données pour le moment"
-
-#, elixir-autogen, elixir-format
-msgid "This feature is currently not available."
-msgstr "La fonctionnalité n'est pas disponible pour le moment."
diff --git a/apps/transport/priv/gettext/fr/LC_MESSAGES/db-dataset.po b/apps/transport/priv/gettext/fr/LC_MESSAGES/db-dataset.po
index bc96cfb20f..f605986ae6 100644
--- a/apps/transport/priv/gettext/fr/LC_MESSAGES/db-dataset.po
+++ b/apps/transport/priv/gettext/fr/LC_MESSAGES/db-dataset.po
@@ -76,8 +76,8 @@ msgid "Charging & refuelling stations"
msgstr "Stations de réapprovisionnement de véhicules"
#, elixir-autogen, elixir-format, fuzzy
-msgid "Public transit - static schedules"
-msgstr "Transport public collectif - horaires théoriques"
+msgid "Public transit"
+msgstr "Transport public collectif"
#, elixir-autogen, elixir-format
msgid "Road data"
diff --git a/apps/transport/test/transport/data_checker_test.exs b/apps/transport/test/transport/data_checker_test.exs
index 44b9be7ced..509c0f3143 100644
--- a/apps/transport/test/transport/data_checker_test.exs
+++ b/apps/transport/test/transport/data_checker_test.exs
@@ -340,7 +340,7 @@ defmodule Transport.DataCheckerTest do
subject: "Nouveaux jeux de données référencés",
text_body: nil,
html_body:
- ~r|
#{dataset.custom_title} - \(Transport public collectif - horaires théoriques\)|
+ ~r|
#{dataset.custom_title} - \(Transport public collectif\)|
)
assert [
diff --git a/apps/transport/test/transport/irve/irve_extractor_test.exs b/apps/transport/test/transport/irve/irve_extractor_test.exs
index 56fe4e97d4..c13b37fa5c 100644
--- a/apps/transport/test/transport/irve/irve_extractor_test.exs
+++ b/apps/transport/test/transport/irve/irve_extractor_test.exs
@@ -117,6 +117,38 @@ defmodule Transport.IRVE.ExtractorTest do
orig_resource
|> Map.put(:index, 0)
|> Map.put(:line_count, 3)
+ |> Map.put(:http_status, 200)
+ |> Map.delete(:url)
+ ]
+ end
+
+ test "handles non-200 response" do
+ resources = [
+ orig_resource = %{
+ url: expected_url = "https://static.data.gouv.fr/resources/something/something.csv",
+ dataset_id: "the-dataset-id",
+ dataset_title: "the-dataset-title",
+ resource_id: "the-resource-id",
+ resource_title: "the-resource-title",
+ valid: true
+ }
+ ]
+
+ Transport.Req.Mock
+ |> expect(:get!, fn _request, options ->
+ assert options[:url] == expected_url
+
+ %Req.Response{
+ status: 404,
+ body: "there is nothing here"
+ }
+ end)
+
+ # parsed resources must be enriched with line count & index, and url removed
+ assert Transport.IRVE.Extractor.download_and_parse_all(resources) == [
+ orig_resource
+ |> Map.put(:index, 0)
+ |> Map.put(:http_status, 404)
|> Map.delete(:url)
]
end
diff --git a/apps/transport/test/transport/jobs/import_gbfs_feed_contact_point_job_test.exs b/apps/transport/test/transport/jobs/import_gbfs_feed_contact_point_job_test.exs
index 25489f5f9d..be33a379f0 100644
--- a/apps/transport/test/transport/jobs/import_gbfs_feed_contact_point_job_test.exs
+++ b/apps/transport/test/transport/jobs/import_gbfs_feed_contact_point_job_test.exs
@@ -209,7 +209,7 @@ defmodule Transport.Test.Transport.Jobs.ImportGBFSFeedContactEmailJobTest do
assert :ok == perform_job(ImportGBFSFeedContactEmailJob, %{})
- assert [first_contact, new_contact] = DB.Contact |> DB.Repo.all() |> Enum.sort_by(& &1.inserted_at)
+ assert [first_contact, new_contact] = DB.Contact |> DB.Repo.all() |> Enum.sort_by(& &1.id)
assert %DB.Contact{id: ^existing_gbfs_contact_id, email: ^gbfs_2_email} = first_contact
assert "Example" == Transport.GBFSMetadata.operator(gbfs_1.url)
diff --git a/apps/transport/test/transport/jobs/oban_logger_test.exs b/apps/transport/test/transport/jobs/oban_logger_test.exs
index f33c27ccce..4b4d449aaa 100644
--- a/apps/transport/test/transport/jobs/oban_logger_test.exs
+++ b/apps/transport/test/transport/jobs/oban_logger_test.exs
@@ -44,4 +44,17 @@ defmodule Transport.Test.Transport.Jobs.ObanLoggerTest do
"Un job Oban Transport.Test.Transport.Jobs.ObanLoggerJobTag vient d'échouer, il serait bien d'investiguer."
)
end
+
+ test "oban default logger is set up for important components" do
+ registered_handlers = Enum.filter(:telemetry.list_handlers([]), &(&1.id == "oban-default-logger"))
+
+ assert Enum.count(registered_handlers) > 0
+
+ components =
+ registered_handlers
+ |> Enum.map(fn %{event_name: [:oban, component, _]} -> component end)
+ |> MapSet.new()
+
+ assert MapSet.new([:notifier, :queue, :stager]) == MapSet.new(components)
+ end
end
diff --git a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs
index f84498b915..c57436d36e 100644
--- a/apps/transport/test/transport_web/controllers/dataset_controller_test.exs
+++ b/apps/transport/test/transport_web/controllers/dataset_controller_test.exs
@@ -850,7 +850,7 @@ defmodule TransportWeb.DatasetControllerTest do
test "dataset-page-title", %{conn: conn} do
[
- {%{"type" => "public-transit"}, "Transport public collectif - horaires théoriques"},
+ {%{"type" => "public-transit"}, "Transport public collectif"},
{%{"type" => "public-transit", "filter" => "has_realtime"}, "Transport public collectif - horaires temps réel"},
{%{"modes" => ["rail"]}, "Transport ferroviaire"}
]
diff --git a/apps/transport/test/transport_web/controllers/dataset_search_test.exs b/apps/transport/test/transport_web/controllers/dataset_search_test.exs
index 29fdd8b474..7c3d8c0349 100644
--- a/apps/transport/test/transport_web/controllers/dataset_search_test.exs
+++ b/apps/transport/test/transport_web/controllers/dataset_search_test.exs
@@ -62,7 +62,7 @@ defmodule TransportWeb.DatasetSearchControllerTest do
test "GET /datasets filter", %{conn: conn} do
conn = conn |> get(dataset_path(conn, :index))
# info dans les filtres à gauche des datasets
- assert html_response(conn, 200) =~ "Transport public collectif - horaires théoriques (2)"
+ assert html_response(conn, 200) =~ "Transport public collectif (2)"
end
describe "list datasets" do
@@ -156,7 +156,7 @@ defmodule TransportWeb.DatasetSearchControllerTest do
test "GET /datasets?type=public-transit&licence=odc-odbl", %{conn: conn} do
conn = conn |> get(dataset_path(conn, :index), %{type: "public-transit", licence: "odc-odbl"})
- assert html_response(conn, 200) =~ "Transport public collectif - horaires théoriques (1)"
+ assert html_response(conn, 200) =~ "Transport public collectif (1)"
assert html_response(conn, 200) =~ "Horaires Angers"
refute html_response(conn, 200) =~ "Horaires Laval"
diff --git a/apps/transport/test/transport_web/controllers/reuser_space_controller_test.exs b/apps/transport/test/transport_web/controllers/reuser_space_controller_test.exs
index 92f760790f..f6ab217596 100644
--- a/apps/transport/test/transport_web/controllers/reuser_space_controller_test.exs
+++ b/apps/transport/test/transport_web/controllers/reuser_space_controller_test.exs
@@ -28,17 +28,6 @@ defmodule TransportWeb.ReuserSpaceControllerTest do
# Feedback form is displayed
refute content |> Floki.parse_document!() |> Floki.find("form.feedback-form") |> Enum.empty?()
end
-
- test "reuser space disabled by killswitch", %{conn: conn} do
- old_value = Application.fetch_env!(:transport, :disable_reuser_space)
- Application.put_env(:transport, :disable_reuser_space, true)
- conn = Plug.Test.init_test_session(conn, %{current_user: %{}})
- refute TransportWeb.Session.display_reuser_space?(conn)
- conn = conn |> get(@home_url)
- assert redirected_to(conn, 302) == "/"
- assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "La fonctionnalité n'est pas disponible pour le moment"
- Application.put_env(:transport, :disable_reuser_space, old_value)
- end
end
describe "datasets_edit" do
diff --git a/apps/transport/test/transport_web/live_views/discussions_live_test.exs b/apps/transport/test/transport_web/live_views/discussions_live_test.exs
index 5f5e7fc469..92e47f0a31 100644
--- a/apps/transport/test/transport_web/live_views/discussions_live_test.exs
+++ b/apps/transport/test/transport_web/live_views/discussions_live_test.exs
@@ -209,7 +209,7 @@ defmodule Transport.TransportWeb.DiscussionsLiveTest do
end
defp iso8601_string_x_months_ago(x) do
- DateTime.utc_now() |> Timex.shift(months: -x) |> DateTime.to_iso8601()
+ DateTime.utc_now() |> TimeWrapper.shift(months: -x) |> DateTime.to_iso8601()
end
defp discussions do
diff --git a/apps/transport/test/transport_web/live_views/followed_datasets_live_test.exs b/apps/transport/test/transport_web/live_views/followed_datasets_live_test.exs
index 023e8f7fe1..8ec358c8ab 100644
--- a/apps/transport/test/transport_web/live_views/followed_datasets_live_test.exs
+++ b/apps/transport/test/transport_web/live_views/followed_datasets_live_test.exs
@@ -27,7 +27,7 @@ defmodule TransportWeb.Live.FollowedDatasetsLiveTest do
{"select", [{"id", "type"}, {"name", "type"}],
[
{"option", [{"selected", "selected"}, {"value", ""}], ["Tout"]},
- {"option", [{"value", "public-transit"}], ["Transport public collectif - horaires théoriques"]},
+ {"option", [{"value", "public-transit"}], ["Transport public collectif"]},
{"option", [{"value", "bike-scooter-sharing"}], ["Vélos et trottinettes en libre-service"]}
]}
] == view |> element("form select") |> render() |> Floki.parse_document!()
diff --git a/apps/transport/test/transport_web/plugs/worker_healthcheck_test.exs b/apps/transport/test/transport_web/plugs/worker_healthcheck_test.exs
new file mode 100644
index 0000000000..ce6da59f9d
--- /dev/null
+++ b/apps/transport/test/transport_web/plugs/worker_healthcheck_test.exs
@@ -0,0 +1,129 @@
+defmodule TransportWeb.Plugs.WorkerHealthcheckTest do
+ # async: false is required because we use real in-memory caching in these tests,
+ # and we swap application config (shared state)
+ use TransportWeb.ConnCase, async: false
+ alias TransportWeb.Plugs.WorkerHealthcheck
+
+ @cache_name Transport.Cache.Cachex.cache_name()
+ @cache_key WorkerHealthcheck.app_start_datetime_cache_key_name()
+
+ setup do
+ # Use a real in-memory cache for these tests to test the caching mecanism
+ old_value = Application.fetch_env!(:transport, :cache_impl)
+ Application.put_env(:transport, :cache_impl, Transport.Cache.Cachex)
+
+ on_exit(fn ->
+ Application.put_env(:transport, :cache_impl, old_value)
+ Cachex.reset(@cache_name)
+ end)
+
+ Ecto.Adapters.SQL.Sandbox.checkout(DB.Repo)
+ end
+
+ describe "healthy_state?" do
+ test "app was started recently, no Oban jobs" do
+ assert WorkerHealthcheck.app_started_recently?()
+ refute WorkerHealthcheck.oban_attempted_jobs_recently?()
+ assert WorkerHealthcheck.healthy_state?()
+ end
+
+ test "app was not started recently, Oban jobs have not been attempted recently" do
+ datetime = DateTime.add(DateTime.utc_now(), -30, :minute)
+ Cachex.put(@cache_name, @cache_key, datetime)
+
+ refute WorkerHealthcheck.app_started_recently?()
+ refute WorkerHealthcheck.oban_attempted_jobs_recently?()
+ refute WorkerHealthcheck.healthy_state?()
+ end
+
+ test "app was not started recently, Oban jobs have been attempted recently" do
+ datetime = DateTime.add(DateTime.utc_now(), -30, :minute)
+ Cachex.put(@cache_name, @cache_key, datetime)
+
+ # A completed job was attempted 55 minutes ago
+ Transport.Jobs.ResourceUnavailableJob.new(%{resource_id: 1})
+ |> Oban.insert!()
+ |> Ecto.Changeset.change(attempted_at: DateTime.add(DateTime.utc_now(), -55, :minute), state: "completed")
+ |> DB.Repo.update!()
+
+ refute WorkerHealthcheck.app_started_recently?()
+ assert WorkerHealthcheck.oban_attempted_jobs_recently?()
+ assert WorkerHealthcheck.healthy_state?()
+ end
+ end
+
+ describe "app_started_recently?" do
+ test "value is set when executed for the first time" do
+ assert {:ok, false} == Cachex.exists?(@cache_name, @cache_key)
+ # Calling for the first time creates the key
+ assert WorkerHealthcheck.app_started_recently?()
+ assert {:ok, true} == Cachex.exists?(@cache_name, @cache_key)
+
+ # Calling again does not refresh the initial value
+ start_datetime = WorkerHealthcheck.app_start_datetime()
+ WorkerHealthcheck.app_started_recently?()
+ assert start_datetime == WorkerHealthcheck.app_start_datetime()
+
+ # Key does not expire
+ assert {:ok, nil} == Cachex.ttl(@cache_name, @cache_key)
+ end
+
+ test "acceptable delay is 20 minutes" do
+ # Just right
+ datetime = DateTime.add(DateTime.utc_now(), -19, :minute)
+ Cachex.put(@cache_name, @cache_key, datetime)
+
+ assert WorkerHealthcheck.app_started_recently?()
+
+ # Too long ago
+ datetime = DateTime.add(DateTime.utc_now(), -21, :minute)
+ Cachex.put(@cache_name, @cache_key, datetime)
+ refute WorkerHealthcheck.app_started_recently?()
+ end
+ end
+
+ describe "oban_attempted_jobs_recently?" do
+ test "job attempted recently" do
+ # Attempted less than 60 minutes ago
+ Transport.Jobs.ResourceUnavailableJob.new(%{resource_id: 1})
+ |> Oban.insert!()
+ |> Ecto.Changeset.change(attempted_at: DateTime.add(DateTime.utc_now(), -59, :minute), state: "completed")
+ |> DB.Repo.update!()
+
+ assert WorkerHealthcheck.oban_attempted_jobs_recently?()
+ end
+
+ test "job attempted too long ago" do
+ # Attempted more than 60 minutes ago
+ Transport.Jobs.ResourceUnavailableJob.new(%{resource_id: 1})
+ |> Oban.insert!()
+ |> Ecto.Changeset.change(attempted_at: DateTime.add(DateTime.utc_now(), -61, :minute), state: "completed")
+ |> DB.Repo.update!()
+
+ refute WorkerHealthcheck.oban_attempted_jobs_recently?()
+ end
+ end
+
+ describe "call" do
+ test "healthy system", %{conn: conn} do
+ assert WorkerHealthcheck.app_started_recently?()
+ refute WorkerHealthcheck.oban_attempted_jobs_recently?()
+ assert WorkerHealthcheck.healthy_state?()
+
+ assert conn |> WorkerHealthcheck.call(if: {__MODULE__, :plug_enabled?}) |> text_response(200)
+ end
+
+ test "unhealthy system", %{conn: conn} do
+ datetime = DateTime.add(DateTime.utc_now(), -30, :minute)
+ Cachex.put(@cache_name, @cache_key, datetime)
+
+ refute WorkerHealthcheck.app_started_recently?()
+ refute WorkerHealthcheck.oban_attempted_jobs_recently?()
+ refute WorkerHealthcheck.healthy_state?()
+
+ assert conn |> WorkerHealthcheck.call(if: {__MODULE__, :plug_enabled?}) |> text_response(503)
+ end
+ end
+
+ def plug_enabled?, do: true
+end
diff --git a/apps/transport/test/transport_web/routing/headers_and_cookies_test.exs b/apps/transport/test/transport_web/routing/headers_and_cookies_test.exs
index 2b1d7bffe5..49d566d0a1 100644
--- a/apps/transport/test/transport_web/routing/headers_and_cookies_test.exs
+++ b/apps/transport/test/transport_web/routing/headers_and_cookies_test.exs
@@ -24,7 +24,7 @@ defmodule TransportWeb.HeadersAndCookiesTest do
"expires" => datetime
} = Plug.Conn.Cookies.decode(header)
- datetime = Timex.parse!(datetime, "{WDshort}, {D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
- assert_in_delta Timex.diff(datetime, Timex.now(), :hours), 15 * 24, 1
+ datetime = TimeWrapper.parse!(datetime, "{WDshort}, {D} {Mshort} {YYYY} {h24}:{m}:{s} GMT")
+ assert_in_delta TimeWrapper.diff(datetime, TimeWrapper.now(), :hours), 15 * 24, 1
end
end
diff --git a/apps/transport/test/transport_web/session_test.exs b/apps/transport/test/transport_web/session_test.exs
index 65b92205a7..7a969102b6 100644
--- a/apps/transport/test/transport_web/session_test.exs
+++ b/apps/transport/test/transport_web/session_test.exs
@@ -55,24 +55,6 @@ defmodule TransportWeb.SessionTest do
end
end
- describe "display_reuser_space?" do
- test "killswitch can disable the reuser space" do
- old_value = Application.fetch_env!(:transport, :disable_reuser_space)
- Application.put_env(:transport, :disable_reuser_space, true)
- conn = Plug.Test.init_test_session(%Plug.Conn{}, %{})
- refute TransportWeb.Session.display_reuser_space?(conn)
- Application.put_env(:transport, :disable_reuser_space, old_value)
- end
-
- test "admins get access when killswitch is enabled" do
- old_value = Application.fetch_env!(:transport, :disable_reuser_space)
- Application.put_env(:transport, :disable_reuser_space, true)
- conn = Plug.Test.init_test_session(%Plug.Conn{}, %{current_user: %{"is_admin" => true}})
- assert TransportWeb.Session.display_reuser_space?(conn)
- Application.put_env(:transport, :disable_reuser_space, old_value)
- end
- end
-
def pan_org do
%{"slug" => "equipe-transport-data-gouv-fr", "name" => "PAN", "id" => @pan_org_id}
end
diff --git a/apps/transport/test/transport_web/views/dataset_view_test.exs b/apps/transport/test/transport_web/views/dataset_view_test.exs
index 4247f881bd..567ca5bf59 100644
--- a/apps/transport/test/transport_web/views/dataset_view_test.exs
+++ b/apps/transport/test/transport_web/views/dataset_view_test.exs
@@ -67,6 +67,68 @@ defmodule TransportWeb.DatasetViewTest do
assert get_resource_to_display(dataset_only_roads) == nil
end
+ test "resource to display for BNLC" do
+ dataset_two_bnlcs = %DB.Dataset{
+ type: "carpooling-areas",
+ resources: [
+ %DB.Resource{
+ id: 1,
+ url: "https://example.com/bnlc.csv",
+ format: "csv",
+ schema_name: "etalab/schema-lieux-covoiturage",
+ last_update: ~U[2016-05-24 13:26:08Z],
+ type: "other"
+ },
+ %DB.Resource{
+ id: 2,
+ url: "https://example.com/bnlc-consolidated.csv",
+ format: "csv",
+ schema_name: "etalab/schema-lieux-covoiturage",
+ last_update: ~U[2016-05-24 13:25:08Z],
+ type: "other"
+ }
+ ]
+ }
+
+ dataset_two_bnlcs_with_the_main = %DB.Dataset{
+ type: "carpooling-areas",
+ resources: [
+ %DB.Resource{
+ id: 1,
+ url: "https://example.com/bnlc.csv",
+ format: "csv",
+ schema_name: "etalab/schema-lieux-covoiturage",
+ last_update: ~U[2016-05-24 13:26:08Z],
+ type: "other"
+ },
+ %DB.Resource{
+ id: 2,
+ url: "https://example.com/bnlc-consolidated-1.csv",
+ format: "csv",
+ schema_name: "etalab/schema-lieux-covoiturage",
+ # not the latest, but we prefer the main one
+ last_update: ~U[2016-05-24 13:24:08Z],
+ type: "main"
+ },
+ %DB.Resource{
+ id: 3,
+ url: "https://example.com/bnlc-consolidated-2.csv",
+ format: "csv",
+ schema_name: "etalab/schema-lieux-covoiturage",
+ # not the latest, but we prefer the main one
+ last_update: ~U[2016-05-24 13:25:08Z],
+ type: "main"
+ }
+ ]
+ }
+
+ # Display the latest
+ assert get_resource_to_display(dataset_two_bnlcs).id == 1
+
+ # Display the latest main one
+ assert get_resource_to_display(dataset_two_bnlcs_with_the_main).id == 3
+ end
+
test "test data is up to date" do
assert "tipi.bison-fute.gouv.fr" == Application.fetch_env!(:transport, :bison_fute_host)
end
diff --git a/config/runtime.exs b/config/runtime.exs
index 3c72728c3e..af99631d5f 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -38,8 +38,8 @@ config :transport,
worker: worker,
webserver: webserver,
# kill switches: set specific variable environments to disable features
- disable_reuser_space: System.get_env("DISABLE_REUSER_SPACE") in ["1", "true"],
- disable_national_gtfs_map: System.get_env("DISABLE_NATIONAL_GTFS_MAP") in ["1", "true"]
+ disable_national_gtfs_map: System.get_env("DISABLE_NATIONAL_GTFS_MAP") in ["1", "true"],
+ disable_netex_validator: System.get_env("DISABLE_NETEX_VALIDATOR") in ["1", "true"]
config :unlock,
enforce_ttl: webserver
diff --git a/mix.lock b/mix.lock
index 63db11d2fe..0f7718d356 100644
--- a/mix.lock
+++ b/mix.lock
@@ -23,7 +23,7 @@
"crontab": {:hex, :crontab, "1.1.13", "3bad04f050b9f7f1c237809e42223999c150656a6b2afbbfef597d56df2144c5", [:mix], [{:ecto, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}], "hexpm", "d67441bec989640e3afb94e123f45a2bc42d76e02988c9613885dc3d01cf7085"},
"csv": {:hex, :csv, "3.2.1", "6d401f1ed33acb2627682a9ab6021e96d33ca6c1c6bccc243d8f7e2197d032f5", [:mix], [], "hexpm", "8f55a0524923ae49e97ff2642122a2ce7c61e159e7fe1184670b2ce847aee6c8"},
"db_connection": {:hex, :db_connection, "2.7.0", "b99faa9291bb09892c7da373bb82cba59aefa9b36300f6145c5f201c7adf48ec", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "dcf08f31b2701f857dfc787fbad78223d61a32204f217f15e881dd93e4bdd3ff"},
- "decimal": {:hex, :decimal, "2.2.0", "df3d06bb9517e302b1bd265c1e7f16cda51547ad9d99892049340841f3e15836", [:mix], [], "hexpm", "af8daf87384b51b7e611fb1a1f2c4d4876b65ef968fa8bd3adf44cff401c7f21"},
+ "decimal": {:hex, :decimal, "2.3.0", "3ad6255aa77b4a3c4f818171b12d237500e63525c2fd056699967a3e7ea20f62", [:mix], [], "hexpm", "a4d66355cb29cb47c3cf30e71329e58361cfcb37c34235ef3bf1d7bf3773aeac"},
"decorator": {:hex, :decorator, "1.4.0", "a57ac32c823ea7e4e67f5af56412d12b33274661bb7640ec7fc882f8d23ac419", [:mix], [], "hexpm", "0a07cedd9083da875c7418dea95b78361197cf2bf3211d743f6f7ce39656597f"},
"dialyxir": {:hex, :dialyxir, "1.4.3", "edd0124f358f0b9e95bfe53a9fcf806d615d8f838e2202a9f430d59566b6b53b", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "bf2cfb75cd5c5006bec30141b131663299c661a864ec7fbbc72dfa557487a986"},
"digital_token": {:hex, :digital_token, "0.6.0", "13e6de581f0b1f6c686f7c7d12ab11a84a7b22fa79adeb4b50eec1a2d278d258", [:mix], [{:cldr_utils, "~> 2.17", [hex: :cldr_utils, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "2455d626e7c61a128b02a4a8caddb092548c3eb613ac6f6a85e4cbb6caddc4d1"},
@@ -88,7 +88,7 @@
"nimble_pool": {:hex, :nimble_pool, "1.1.0", "bf9c29fbdcba3564a8b800d1eeb5a3c58f36e1e11d7b7fb2e084a643f645f06b", [:mix], [], "hexpm", "af2e4e6b34197db81f7aad230c1118eac993acc0dae6bc83bac0126d4ae0813a"},
"nx": {:hex, :nx, "0.7.3", "51ff45d9f9ff58b616f4221fa54ccddda98f30319bb8caaf86695234a469017a", [:mix], [{:complex, "~> 0.5", [hex: :complex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "5ff29af84f08db9bda66b8ef7ce92ab583ab4f983629fe00b479f1e5c7c705a6"},
"oauth2": {:hex, :oauth2, "2.1.0", "beb657f393814a3a7a8a15bd5e5776ecae341fd344df425342a3b6f1904c2989", [:mix], [{:tesla, "~> 1.5", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "8ac07f85b3307dd1acfeb0ec852f64161b22f57d0ce0c15e616a1dfc8ebe2b41"},
- "oban": {:hex, :oban, "2.18.0", "092d20bfd3d70c7ecb70960f8548d300b54bb9937c7f2e56b388f3a9ed02ec68", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "aace1eff6f8227ae38d4274af967d96f051c2f0a5152f2ef9809dd1f97866745"},
+ "oban": {:hex, :oban, "2.18.3", "1608c04f8856c108555c379f2f56bc0759149d35fa9d3b825cb8a6769f8ae926", [:mix], [{:ecto_sql, "~> 3.10", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:ecto_sqlite3, "~> 0.9", [hex: :ecto_sqlite3, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16", [hex: :postgrex, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "36ca6ca84ef6518f9c2c759ea88efd438a3c81d667ba23b02b062a0aa785475e"},
"open_api_spex": {:hex, :open_api_spex, "3.20.0", "d4fcf1ee297aa94a673cddb92734eb0bc7cac698be93949a223a50f724e3af89", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 3.0 or ~> 4.0 or ~> 5.0 or ~> 6.0", [hex: :poison, repo: "hexpm", optional: true]}, {:ymlr, "~> 2.0 or ~> 3.0 or ~> 4.0 or ~> 5.0", [hex: :ymlr, repo: "hexpm", optional: true]}], "hexpm", "2e9beea71142ff09f8f935579b39406e2c6b5a3978e7235978d7faf2f90cd081"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
"phoenix": {:hex, :phoenix, "1.7.14", "a7d0b3f1bc95987044ddada111e77bd7f75646a08518942c72a8440278ae7825", [:mix], [{:castore, ">= 0.0.0", [hex: :castore, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "c7859bc56cc5dfef19ecfc240775dae358cbaa530231118a9e014df392ace61a"},