Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(Store.Predictions): Add log when record removed for debugging #216

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/mbta_v3_api/store/predictions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ defmodule MBTAV3API.Store.Predictions.Impl do
@impl true
def process_remove(references) do
for reference <- references do
Logger.info("#{__MODULE__} process_remove #{inspect(reference)}")

case reference do
%{type: "prediction", id: id} -> :ets.delete(@predictions_table_name, id)
%{type: "trip", id: id} -> :ets.delete(@trips_table_name, id)
Expand Down
17 changes: 13 additions & 4 deletions test/mbta_v3_api/store/predictions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,27 @@ defmodule MBTAV3API.Store.PredictionsTest do
} = Store.Predictions.fetch_with_associations(stop_id: "12345")
end

@tag :capture_log
test "process_remove", %{
prediction_1: prediction_1,
prediction_2: prediction_2,
trip_1: trip_1,
trip_2: trip_2
} do
set_log_level(:info)

Store.Predictions.process_upsert(:add, [prediction_1, prediction_2, trip_1, trip_2])

Store.Predictions.process_remove([
%Reference{type: "prediction", id: prediction_1.id},
%Reference{type: "trip", id: trip_1.id}
])
msg =
capture_log([level: :info], fn ->
Store.Predictions.process_remove([
%Reference{type: "prediction", id: prediction_1.id},
%Reference{type: "trip", id: trip_1.id}
])
end)

assert msg =~ "process_remove %MBTAV3API.JsonApi.Reference{type: \"prediction\", id: \"1\"}"
assert msg =~ "process_remove %MBTAV3API.JsonApi.Reference{type: \"trip\", id: \"trip_1\"}"

assert JsonApi.Object.to_full_map([prediction_2, trip_2]) ==
Store.Predictions.fetch_with_associations(stop_id: "12345")
Expand Down
Loading