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

tweak: Include triptych player name in data request logs #1867

Merged
merged 2 commits into from
Sep 18, 2023
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
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
Loading