Skip to content

Commit

Permalink
Replace local config code with library config code (#1886)
Browse files Browse the repository at this point in the history
* Replace local config code with library config code

* credo

* Update Architecture.md

* Revise since fetching logic will probably move soon

* point readers to new repo
  • Loading branch information
PaulJKim authored Oct 18, 2023
1 parent 2520383 commit 31f3885
Show file tree
Hide file tree
Showing 178 changed files with 242 additions and 2,838 deletions.
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Server:
| Module or directory | Description |
| - | - |
| [`ScreenData`](/lib/screens/v2/screen_data.ex) | Common logic to answer all screen data requests. We try to keep this code agnostic of widget implementation details and free of business logic. Code changes infrequently. If a new feature is needed on _all_ screen types, the change might happen here. |
| [`config` directory](/lib/screens/config/) | Contains modules that define the config schema for each screen type, and how to convert it to/from JSON. Most modules `use` a macro from [`config/struct.ex`](/lib/screens/config/struct.ex) to simplify defining their data structures. |
| [`config` directory](/lib/screens/config/) | Contains modules used for caching screen configs from S3. Modules that define the config schema for each screen type, and how to convert it to/from JSON now live in the [screens-config-lib](https://github.com/mbta/screens-config-lib) repo|
| [Candidate generators](/lib/screens/v2/candidate_generator/) | These modules define "step 1" for producing the data response for each screen type. Each one adopts the [`CandidateGenerator`](/lib/screens/v2/candidate_generator.ex) behaviour, and contains code that defines the screen's visual template as well as functions to fetch data and transform it into widgets to populate that template. |
| [`Template`](/lib/screens/v2/template.ex) | Contains types and functions related to screen templates. |
| [`WidgetInstance`](/lib/screens/v2/widget_instance.ex) | Defines the common protocol that all widgets must implement. The framework code in `ScreenData` calls these protocol functions on widgets to fit them into a screen template and produce the JSON response. |
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/bus_screen_data.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ defmodule Screens.BusScreenData do
@moduledoc false

alias Screens.Alerts.Alert
alias Screens.Config.State
alias Screens.Departures.Departure
alias Screens.LogScreenData
alias Screens.NearbyConnections
alias Screens.Schedules.Schedule
alias Screens.Config.{Bus, State}
alias Screens.Util
alias ScreensConfig.Bus

def by_screen_id(screen_id, is_screen, now \\ DateTime.utc_now()) do
if State.mode_disabled?(:bus) do
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/config.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule Screens.Config do
@moduledoc false

alias Screens.Config.{Devops, Screen}
alias ScreensConfig.{Devops, Screen}

@type t :: %__MODULE__{
screens: %{
Expand All @@ -16,7 +16,7 @@ defmodule Screens.Config do
defstruct screens: nil,
devops: Devops.from_json(:default)

use Screens.Config.Struct, children: [screens: {:map, Screen}, devops: Devops]
use ScreensConfig.Struct, children: [screens: {:map, Screen}, devops: Devops]

@spec schedule_refresh_for_screen_ids(t(), list(String.t()), DateTime.t()) :: t()
def schedule_refresh_for_screen_ids(config, screen_ids, now \\ DateTime.utc_now()) do
Expand Down
67 changes: 0 additions & 67 deletions lib/screens/config/audio_psa.ex

This file was deleted.

16 changes: 0 additions & 16 deletions lib/screens/config/behaviour.ex

This file was deleted.

26 changes: 0 additions & 26 deletions lib/screens/config/bus.ex

This file was deleted.

26 changes: 0 additions & 26 deletions lib/screens/config/devops.ex

This file was deleted.

34 changes: 0 additions & 34 deletions lib/screens/config/dup.ex

This file was deleted.

19 changes: 0 additions & 19 deletions lib/screens/config/dup/departures.ex

This file was deleted.

81 changes: 0 additions & 81 deletions lib/screens/config/dup/override.ex

This file was deleted.

47 changes: 0 additions & 47 deletions lib/screens/config/dup/override/fullscreen_alert.ex

This file was deleted.

21 changes: 0 additions & 21 deletions lib/screens/config/dup/override/fullscreen_image.ex

This file was deleted.

Loading

0 comments on commit 31f3885

Please sign in to comment.