Skip to content

Commit

Permalink
Bubble up HTTP status
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed Dec 17, 2024
1 parent b241f9b commit 7ee6ba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/transport/lib/irve/extractor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ defmodule Transport.IRVE.Extractor do
|> Enum.map(fn x ->
Map.take(x, [
:dataset_id,
:http_status,
:dataset_title,
:dataset_organisation_name,
:dataset_organisation_url,
Expand All @@ -133,7 +134,7 @@ defmodule Transport.IRVE.Extractor do
Transport.IRVE.Fetcher.get!(row[:url], compressed: false, decode_body: false)

row
|> Map.put(:status, status)
|> Map.put(:http_status, status)
|> Map.put(:index, index)
|> then(fn x -> process_resource_body(x, body) end)
end
Expand All @@ -142,7 +143,7 @@ defmodule Transport.IRVE.Extractor do
For a given resource and corresponding body, enrich data with
extra stuff like estimated number of charge points.
"""
def process_resource_body(%{status: 200} = row, body) do
def process_resource_body(%{http_status: 200} = row, body) do
body = body |> String.split("\n")
first_line = body |> hd()
line_count = (body |> length) - 1
Expand Down
2 changes: 2 additions & 0 deletions apps/transport/test/transport/irve/irve_extractor_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ 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
Expand Down Expand Up @@ -147,6 +148,7 @@ defmodule Transport.IRVE.ExtractorTest do
assert Transport.IRVE.Extractor.download_and_parse_all(resources) == [
orig_resource
|> Map.put(:index, 0)
|> Map.put(:http_status, 404)
|> Map.delete(:url)
]
end
Expand Down

0 comments on commit 7ee6ba2

Please sign in to comment.