diff --git a/lib/screens/v2/screen_data.ex b/lib/screens/v2/screen_data.ex index 6033251d9..fe9879bc6 100644 --- a/lib/screens/v2/screen_data.ex +++ b/lib/screens/v2/screen_data.ex @@ -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 :: %{ diff --git a/lib/screens/v2/widget_instance/departures.ex b/lib/screens/v2/widget_instance/departures.ex index c9f268501..e310e87b1 100644 --- a/lib/screens/v2/widget_instance/departures.ex +++ b/lib/screens/v2/widget_instance/departures.ex @@ -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 diff --git a/lib/screens/v2/widget_instance/line_map.ex b/lib/screens/v2/widget_instance/line_map.ex index 188d0312c..24805bacf 100644 --- a/lib/screens/v2/widget_instance/line_map.ex +++ b/lib/screens/v2/widget_instance/line_map.ex @@ -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 diff --git a/lib/screens/v2/widget_instance/normal_header.ex b/lib/screens/v2/widget_instance/normal_header.ex index a9584b8d1..86c87a7b6 100644 --- a/lib/screens/v2/widget_instance/normal_header.ex +++ b/lib/screens/v2/widget_instance/normal_header.ex @@ -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}, diff --git a/lib/screens_web/controllers/v2/screen_controller.ex b/lib/screens_web/controllers/v2/screen_controller.ex index ff1889a7c..0803ad446 100644 --- a/lib/screens_web/controllers/v2/screen_controller.ex +++ b/lib/screens_web/controllers/v2/screen_controller.ex @@ -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} ->