Skip to content

Commit

Permalink
tweak: Include triptych player name in data request logs (#1867)
Browse files Browse the repository at this point in the history
* tweak: Include triptych player name in data request logs

* Appease Credo
  • Loading branch information
jzimbel-mbta authored Sep 18, 2023
1 parent 5a8d322 commit 44c1a8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
20 changes: 15 additions & 5 deletions lib/screens/log_screen_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ defmodule Screens.LogScreenData do
screen_id,
last_refresh,
is_screen,
requestor,
screen_side \\ nil,
rotation_index \\ nil,
triptych_pane \\ nil,
ofm_app_package_version \\ nil
params
) do
requestor = params["requestor"]

if is_screen or not is_nil(requestor) do
screen_side = params["screen_side"]
rotation_index = params["rotation_index"]
triptych_pane = params["pane"]
triptych_player_name = params["player_name"]
ofm_app_package_version = params["version"]

data =
%{
screen_id: screen_id,
Expand All @@ -34,6 +38,7 @@ defmodule Screens.LogScreenData do
|> insert_requestor(requestor)
|> insert_dup_rotation_index(rotation_index)
|> insert_triptych_pane(triptych_pane)
|> insert_triptych_player_name(triptych_player_name)
|> insert_version(ofm_app_package_version)

log_message("[screen data request]", data)
Expand Down Expand Up @@ -156,6 +161,11 @@ defmodule Screens.LogScreenData do
defp insert_triptych_pane(data, triptych_pane),
do: Map.put(data, :triptych_pane, triptych_pane)

defp insert_triptych_player_name(data, nil), do: data

defp insert_triptych_player_name(data, triptych_player_name),
do: Map.put(data, :triptych_player_name, triptych_player_name)

defp insert_version(data, nil), do: data
defp insert_version(data, version), do: Map.put(data, :ofm_app_package_version, version)
end
6 changes: 2 additions & 4 deletions lib/screens_web/controllers/screen_api_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule ScreensWeb.ScreenApiController do
screen_id,
last_refresh,
is_screen,
params["requestor"]
params
)

if nonexistent_screen?(screen_id) do
Expand All @@ -60,9 +60,7 @@ defmodule ScreensWeb.ScreenApiController do
screen_id,
nil,
is_screen,
params["requestor"],
nil,
rotation_index
params
)

if nonexistent_screen?(screen_id) do
Expand Down
11 changes: 2 additions & 9 deletions lib/screens_web/controllers/v2/screen_api_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,13 @@ defmodule ScreensWeb.V2.ScreenApiController do
def show(conn, %{"id" => screen_id, "last_refresh" => last_refresh} = params) do
is_screen = ScreensWeb.UserAgent.is_screen_conn?(conn, screen_id)
screen_side = params["screen_side"]
rotation_index = params["rotation_index"]
triptych_pane = params["pane"]
ofm_app_package_version = params["version"]

LogScreenData.log_data_request(
screen_id,
last_refresh,
is_screen,
params["requestor"],
screen_side,
rotation_index,
triptych_pane,
ofm_app_package_version
params
)

cond do
Expand Down Expand Up @@ -115,8 +109,7 @@ defmodule ScreensWeb.V2.ScreenApiController do
screen_id,
last_refresh,
false,
params["requestor"],
params["screen_side"]
params
)

cond do
Expand Down

0 comments on commit 44c1a8c

Please sign in to comment.