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: Comment Mercury logic #2175

Merged
merged 1 commit into from
Aug 30, 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/screens/v2/screen_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ defmodule Screens.V2.ScreenData do
data: serializable_map() | nil,
force_reload: boolean(),
disabled: boolean(),
# Mercury uses this to help optimize data refreshes
# https://app.asana.com/0/1185117109217413/1205234924224431/f
last_deploy_timestamp: DateTime.t()
}
@type paging_metadata :: %{
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/v2/widget_instance/departures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ defmodule Screens.V2.WidgetInstance.Departures do
serialize_timestamp(departure_time, now)
end

# time_in_epoch is used by Mercury so they can calculate timestamps on their own.
# https://app.asana.com/0/1176097567827729/1205730972991228/f
%{time: time, time_in_epoch: DateTime.to_unix(departure_time)}
end

Expand Down
2 changes: 2 additions & 0 deletions lib/screens/v2/widget_instance/line_map.ex
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ defmodule Screens.V2.WidgetInstance.LineMap do
if index < 0 do
[]
else
# time_in_epoch is used by Mercury so they can calculate times on their own.
# https://app.asana.com/0/1176097567827729/1205730972991228/f
departure_time_epoch = d |> Departure.time() |> DateTime.to_unix()
[%{id: vehicle_id, index: index, label: label, time_in_epoch: departure_time_epoch}]
end
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/v2/widget_instance/normal_header.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defmodule Screens.V2.WidgetInstance.NormalHeader do
time: DateTime.t()
}

# Mercury adds their own time so we omit the time in the response.
# https://app.asana.com/0/1185117109217413/1206070378353406/f
def serialize(
%__MODULE__{
screen: %Screen{vendor: :mercury, app_id: :gl_eink_v2},
Expand Down
2 changes: 2 additions & 0 deletions lib/screens_web/controllers/v2/screen_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ defmodule ScreensWeb.V2.ScreenController do

# Handles widget page GET requests with widget data as a query param.
# Phoenix does not automatically decode JSON received in query params.
# Primarily used by Mercury so not all requests need to run through the framework.
# https://app.asana.com/0/1185117109217413/1205234924224431/f
def widget(conn, %{"app_id" => app_id, "widget" => json_data}) when is_binary(json_data) do
case Jason.decode(json_data) do
{:ok, widget_data} ->
Expand Down
Loading