Skip to content

Commit 1e04d93

Browse files
committed
feat: support multiple stop IDs in alerts config
1 parent 9550369 commit 1e04d93

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/config/alerts.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
defmodule ScreensConfig.Alerts do
22
@moduledoc false
33

4-
@type t :: %__MODULE__{stop_id: String.t()}
4+
@type t :: %__MODULE__{stop_ids: [String.t()]}
55

6-
@enforce_keys [:stop_id]
6+
@enforce_keys [:stop_ids]
77
defstruct @enforce_keys
88

99
use ScreensConfig.Struct
1010

11-
defp value_from_json(_, value), do: value
11+
# Migrate from the previous format which only supported a singular `stop_id`.
12+
defp migrate_json(%{"stop_id" => stop_id} = json), do: Map.put(json, "stop_ids", [stop_id])
13+
defp migrate_json(other), do: other
1214

15+
defp value_from_json(_, value), do: value
1316
defp value_to_json(_, value), do: value
1417
end

0 commit comments

Comments
 (0)