Skip to content

Commit

Permalink
log when a remove event occurs (#1815)
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyshull authored Dec 4, 2023
1 parent 924f58e commit ad8f840
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/predictions/lib/store.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ defmodule Predictions.Store do
"""
use GenServer

require Logger

alias Predictions.Prediction
alias Routes.Route
alias Schedules.Trip
Expand Down Expand Up @@ -46,11 +48,14 @@ defmodule Predictions.Store do

@impl true
def handle_cast({event, predictions}, table) when event in [:add, :update, :reset] do
_ = :ets.insert(table, Enum.map(predictions, &to_record/1))
:ets.insert(table, Enum.map(predictions, &to_record/1))

{:noreply, table}
end

def handle_cast({:remove, predictions}, table) do
Logger.info("Remove predictions event: #{inspect(Enum.map(predictions, & &1.id))}")

for id <- Enum.map(predictions, & &1.id) do
:ets.delete(table, id)
end
Expand Down

0 comments on commit ad8f840

Please sign in to comment.