Skip to content

Commit

Permalink
When non-200 status is seen, ignore actual validity
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed Dec 17, 2024
1 parent 5677b64 commit 436d506
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ defmodule TransportWeb.Backoffice.IRVEDashboardLive do

filtering_expression == "" ||
String.contains?(resource["dataset_organisation_name"] |> String.downcase(), filtering_expression) ||
String.contains?(format_validity(resource["valid"]) |> inspect |> String.downcase(), filtering_expression)
String.contains?(format_validity(resource["valid"], resource["http_status"]) |> inspect |> String.downcase(), filtering_expression)
end

def assign_data(socket) do
Expand Down Expand Up @@ -119,7 +119,9 @@ defmodule TransportWeb.Backoffice.IRVEDashboardLive do
|> Enum.sort_by(fn x -> x["line_count"] end, :desc)
end

def format_validity(false), do: {:safe, "<strong class='red'>KO</strong>"}
def format_validity(true), do: "OK"
def format_validity(nil), do: "Non testé"
def format_validity(false, 200), do: {:safe, "<strong class='red'>KO</strong>"}
def format_validity(true, 200), do: "OK"
def format_validity(nil, 200), do: "Non testé"
# mostly there to handle 404/500. Ignore validity and assume the resource is not reachable at all
def format_validity(_validity, http_status), do: {:safe, "<strong class='red'>KO (#{http_status})</strong>"}
end
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
&mdash; <%= resource["last_modified"] |> String.slice(0..15) %>
</td>
<td>
<%= format_validity(resource["valid"]) %>
<%= format_validity(resource["valid"], resource["http_status"]) %>
</td>
<td><%= format_number_maybe_nil(resource["line_count"], nil_result: "???") %></td>
</tr>
Expand Down

0 comments on commit 436d506

Please sign in to comment.