diff --git a/apps/transport/lib/db/resource.ex b/apps/transport/lib/db/resource.ex index 93cf5c4b9f..cbdc76bca0 100644 --- a/apps/transport/lib/db/resource.ex +++ b/apps/transport/lib/db/resource.ex @@ -90,9 +90,6 @@ defmodule DB.Resource do query |> where([resource: r], r.dataset_id == ^dataset_id) end - @spec endpoint() :: binary() - def endpoint, do: Application.fetch_env!(:transport, :gtfs_validator_url) <> "/validate" - def changeset(resource, params) do resource |> cast( diff --git a/apps/transport/lib/transport_web/templates/resource/_coordinates_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_coordinates_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_coordinates_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_coordinates_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_duplicate_stop_sequence_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_duplicate_stop_sequence_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_duplicate_stop_sequence_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_duplicate_stop_sequence_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_duplicate_stops_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_duplicate_stops_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_duplicate_stops_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_duplicate_stops_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_extra_file_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_extra_file_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_extra_file_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_extra_file_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_generic_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_generic_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_generic_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_generic_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_invalid_shape_id_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_invalid_shape_id_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_invalid_shape_id_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_invalid_shape_id_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_missing_file_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_missing_file_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_missing_file_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_missing_file_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_missing_id_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_missing_id_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_missing_id_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_missing_id_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_missing_name_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_missing_name_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_missing_name_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_missing_name_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_negative_stop_duration_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_negative_stop_duration_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_negative_stop_duration_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_negative_stop_duration_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_speed_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_speed_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_speed_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_speed_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_subfolder_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_subfolder_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_subfolder_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_subfolder_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_unloadable_model_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_unloadable_model_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_unloadable_model_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_unloadable_model_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_unused_shape_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_unused_shape_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_unused_shape_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_unused_shape_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/_unused_stop_issue.html.heex b/apps/transport/lib/transport_web/templates/resource/_gtfs_unused_stop_issue.html.heex similarity index 100% rename from apps/transport/lib/transport_web/templates/resource/_unused_stop_issue.html.heex rename to apps/transport/lib/transport_web/templates/resource/_gtfs_unused_stop_issue.html.heex diff --git a/apps/transport/lib/transport_web/templates/resource/gtfs_details.html.heex b/apps/transport/lib/transport_web/templates/resource/gtfs_details.html.heex index 0289ffe5de..b7099eaf3a 100644 --- a/apps/transport/lib/transport_web/templates/resource/gtfs_details.html.heex +++ b/apps/transport/lib/transport_web/templates/resource/gtfs_details.html.heex @@ -112,7 +112,7 @@ associated_netex = get_associated_netex(@related_files) %> path: &resource_path/4, action: :details ) %> - <%= render(template(@issues), issues: @issues || [], conn: @conn) %> + <%= render(gtfs_template(@issues), issues: @issues || [], conn: @conn) %> <% end %>

diff --git a/apps/transport/lib/transport_web/templates/validation/show.html.heex b/apps/transport/lib/transport_web/templates/validation/show.html.heex index 29c713a3ec..d3ad86ac72 100644 --- a/apps/transport/lib/transport_web/templates/validation/show.html.heex +++ b/apps/transport/lib/transport_web/templates/validation/show.html.heex @@ -40,7 +40,7 @@ path: &validation_path/4, action: :show ) %> - <%= render(template(@issues), issues: @issues || [], conn: @conn) %> + <%= render(gtfs_template(@issues), issues: @issues || [], conn: @conn) %>

<%= pagination_links(@conn, @issues, [@validation_id], issue_type: issue_type(@issues.entries), diff --git a/apps/transport/lib/transport_web/views/resource_view.ex b/apps/transport/lib/transport_web/views/resource_view.ex index b7c06cd9d2..16962cb3b6 100644 --- a/apps/transport/lib/transport_web/views/resource_view.ex +++ b/apps/transport/lib/transport_web/views/resource_view.ex @@ -24,31 +24,34 @@ defmodule TransportWeb.ResourceView do def issue_type([]), do: nil def issue_type([h | _]), do: h["issue_type"] - def template(issues) do - Map.get( - %{ - "UnloadableModel" => "_unloadable_model_issue.html", - "DuplicateStops" => "_duplicate_stops_issue.html", - "DuplicateStopSequence" => "_duplicate_stop_sequence_issue.html", - "ExtraFile" => "_extra_file_issue.html", - "MissingFile" => "_missing_file_issue.html", - "NullDuration" => "_speed_issue.html", - "ExcessiveSpeed" => "_speed_issue.html", - "NegativeTravelTime" => "_speed_issue.html", - "Slow" => "_speed_issue.html", - "UnusedStop" => "_unused_stop_issue.html", - "InvalidCoordinates" => "_coordinates_issue.html", - "MissingCoordinates" => "_coordinates_issue.html", - "UnusedShapeId" => "_unused_shape_issue.html", - "InvalidShapeId" => "_invalid_shape_id_issue.html", - "MissingId" => "_missing_id_issue.html", - "MissingName" => "_missing_name_issue.html", - "SubFolder" => "_subfolder_issue.html", - "NegativeStopDuration" => "_negative_stop_duration_issue.html" - }, - issue_type(issues.entries), - "_generic_issue.html" - ) + def gtfs_template(issues) do + template = + Map.get( + %{ + "UnloadableModel" => "_unloadable_model_issue.html", + "DuplicateStops" => "_duplicate_stops_issue.html", + "DuplicateStopSequence" => "_duplicate_stop_sequence_issue.html", + "ExtraFile" => "_extra_file_issue.html", + "MissingFile" => "_missing_file_issue.html", + "NullDuration" => "_speed_issue.html", + "ExcessiveSpeed" => "_speed_issue.html", + "NegativeTravelTime" => "_speed_issue.html", + "Slow" => "_speed_issue.html", + "UnusedStop" => "_unused_stop_issue.html", + "InvalidCoordinates" => "_coordinates_issue.html", + "MissingCoordinates" => "_coordinates_issue.html", + "UnusedShapeId" => "_unused_shape_issue.html", + "InvalidShapeId" => "_invalid_shape_id_issue.html", + "MissingId" => "_missing_id_issue.html", + "MissingName" => "_missing_name_issue.html", + "SubFolder" => "_subfolder_issue.html", + "NegativeStopDuration" => "_negative_stop_duration_issue.html" + }, + issue_type(issues.entries), + "_generic_issue.html" + ) + + "_gtfs#{template}" end @spec action_path(Plug.Conn.t()) :: any diff --git a/apps/transport/lib/transport_web/views/validation_view.ex b/apps/transport/lib/transport_web/views/validation_view.ex index 8d449969c9..1ac865d3f3 100644 --- a/apps/transport/lib/transport_web/views/validation_view.ex +++ b/apps/transport/lib/transport_web/views/validation_view.ex @@ -1,7 +1,7 @@ defmodule TransportWeb.ValidationView do use TransportWeb, :view import Phoenix.Controller, only: [current_url: 1] - import TransportWeb.ResourceView, only: [issue_type: 1, template: 1] + import TransportWeb.ResourceView, only: [issue_type: 1, gtfs_template: 1] import TransportWeb.PaginationHelpers def render("_" <> _ = partial, assigns) do diff --git a/apps/transport/lib/validators/gtfs_transport_validator.ex b/apps/transport/lib/validators/gtfs_transport_validator.ex index 116118a70b..75c44584c3 100644 --- a/apps/transport/lib/validators/gtfs_transport_validator.ex +++ b/apps/transport/lib/validators/gtfs_transport_validator.ex @@ -105,6 +105,16 @@ defmodule Transport.Validators.GTFSTransport do def get_issues(_, _), do: [] + @doc """ + iex> validation_result = %{"tooClose" => [%{"severity" => "Warning"}], "funnyName" => [%{"severity" => "Information"}]} + iex> summary(validation_result) + [ + {"Warning", [{"tooClose", %{count: 1, severity: "Warning", title: nil}}]}, + {"Information", [{"funnyName", %{count: 1, severity: "Information", title: nil}}]} + ] + iex> summary(%{}) + [] + """ @spec summary(map) :: list def summary(%{} = validation_result) do validation_result