diff --git a/assets/ts/__v3api.d.ts b/assets/ts/__v3api.d.ts index b04953ba1d..f4c8a3e59f 100644 --- a/assets/ts/__v3api.d.ts +++ b/assets/ts/__v3api.d.ts @@ -349,20 +349,19 @@ export interface Shape { } export interface RoutePattern { - typicality: 1 | 2 | 3 | 4; - time_desc: string | null; - route_id: string; + canonical: boolean; + direction_id: DirectionId; + headsign: string; + id: string; + name: string; representative_trip_id: string; representative_trip_polyline: string; + route_id: string; shape_id: string; - shape_priority: number; - stop_ids: string[]; - headsign: string; - name: string; - id: string; - direction_id: DirectionId; sort_order: number; - canonical: boolean; + stop_ids: string[]; + time_desc: string | null; + typicality: 0 | 1 | 2 | 3 | 4 | 5; } export interface StopHours { diff --git a/assets/ts/schedule/components/ScheduleDirection.tsx b/assets/ts/schedule/components/ScheduleDirection.tsx index e60779d330..bc215bbaed 100644 --- a/assets/ts/schedule/components/ScheduleDirection.tsx +++ b/assets/ts/schedule/components/ScheduleDirection.tsx @@ -148,10 +148,6 @@ const ScheduleDirection = ({ if (result.length === 0 || current.typicality < result[0].typicality) return [current]; if (current.typicality === result[0].typicality) { - if (result[0].shape_priority < 0 && current.shape_priority > 0) - return [current]; - if (current.shape_priority < 0 && result[0].shape_priority > 0) - return result; return result.concat(current); } return result; diff --git a/assets/ts/schedule/components/__schedule.d.ts b/assets/ts/schedule/components/__schedule.d.ts index a75e1e1ef5..35f01bdbbb 100644 --- a/assets/ts/schedule/components/__schedule.d.ts +++ b/assets/ts/schedule/components/__schedule.d.ts @@ -14,7 +14,6 @@ import { export interface EnhancedRoutePattern extends RoutePattern { shape_id: string; - shape_priority: number; headsign: string; } diff --git a/assets/ts/schedule/components/__tests__/ScheduleFinderTest.tsx b/assets/ts/schedule/components/__tests__/ScheduleFinderTest.tsx index cc418b7279..9c1578b602 100644 --- a/assets/ts/schedule/components/__tests__/ScheduleFinderTest.tsx +++ b/assets/ts/schedule/components/__tests__/ScheduleFinderTest.tsx @@ -141,7 +141,6 @@ const routePatternsByDirection = { typicality: 1, time_desc: "School Trip", shape_id: "9840004", - shape_priority: 1, route_id: "CR-Fitchburg", representative_trip_id: "CR-Weekday-Spring-19-401", representative_trip_polyline: "qwerty123@777njhgb", @@ -159,7 +158,6 @@ const routePatternsByDirection = { typicality: 1, time_desc: "School Trip", shape_id: "9840003", - shape_priority: 1, route_id: "CR-Fitchburg", representative_trip_id: "CR-Weekday-Spring-19-400", representative_trip_polyline: "lkjhg987bvcxz88!", diff --git a/assets/ts/schedule/components/__tests__/test-data/routePatternsByDirectionData.json b/assets/ts/schedule/components/__tests__/test-data/routePatternsByDirectionData.json index 8a8176a52d..e784de6f9e 100644 --- a/assets/ts/schedule/components/__tests__/test-data/routePatternsByDirectionData.json +++ b/assets/ts/schedule/components/__tests__/test-data/routePatternsByDirectionData.json @@ -4,7 +4,6 @@ "typicality": 1, "time_desc": null, "shape_id": "shape-1", - "shape_priority": 1, "route_id": "route-1", "representative_trip_id": "trip-1", "representative_trip_polyline": "trip-1-polyline", @@ -25,7 +24,6 @@ "typicality": 1, "time_desc": null, "shape_id": "shape-3", - "shape_priority": 1, "route_id": "route-1", "representative_trip_id": "trip-3", "representative_trip_polyline": "trip-3-polyline", @@ -46,7 +44,6 @@ "typicality": 3, "time_desc": null, "shape_id": "shape-4", - "shape_priority": 1, "route_id": "route-1", "representative_trip_id": "trip-4", "representative_trip_polyline": "trip-4-polyline", @@ -69,7 +66,6 @@ "typicality": 2, "time_desc": null, "shape_id": "shape-2", - "shape_priority": 1, "route_id": "route-1", "representative_trip_id": "trip-1", "representative_trip_polyline": "trip-2-polyline", diff --git a/assets/ts/schedule/components/direction/__tests__/BusMenuTest.tsx b/assets/ts/schedule/components/direction/__tests__/BusMenuTest.tsx index 6d1da9309a..258496bf6b 100644 --- a/assets/ts/schedule/components/direction/__tests__/BusMenuTest.tsx +++ b/assets/ts/schedule/components/direction/__tests__/BusMenuTest.tsx @@ -21,7 +21,6 @@ const routePatterns: EnhancedRoutePattern[] = [ stop_ids: ["123", "456", "789"], route_id: "66", shape_id: "660140", - shape_priority: 1, time_desc: null, typicality: 1, sort_order: 5, @@ -30,7 +29,6 @@ const routePatterns: EnhancedRoutePattern[] = [ { typicality: 3, time_desc: "School days only", - shape_priority: 1, shape_id: "660141-2", route_id: "66", representative_trip_id: "43773700_2", diff --git a/assets/ts/schedule/components/direction/__tests__/reducer-test.tsx b/assets/ts/schedule/components/direction/__tests__/reducer-test.tsx index 74ecd9797f..7bad98ac70 100644 --- a/assets/ts/schedule/components/direction/__tests__/reducer-test.tsx +++ b/assets/ts/schedule/components/direction/__tests__/reducer-test.tsx @@ -13,7 +13,6 @@ const routePatternsForInbound: EnhancedRoutePattern[] = [ stop_ids: ["123", "456", "789"], route_id: "111", shape_id: "1110177", - shape_priority: 1, time_desc: null, typicality: 1, sort_order: 1, @@ -29,7 +28,6 @@ const routePatternsForInbound: EnhancedRoutePattern[] = [ stop_ids: ["123", "555", "789"], route_id: "111", shape_id: "1110157", - shape_priority: 1, time_desc: "Weekdays only", typicality: 2, sort_order: 2, @@ -56,7 +54,6 @@ const initialState: State = { representative_trip_polyline: "asdf444$hhhhmnb", stop_ids: ["123", "555", "777"], route_id: "111", - shape_priority: 1, shape_id: "1110180", time_desc: null, typicality: 1, @@ -90,7 +87,6 @@ it("menuReducer handles 'toggleDirection'", () => { stop_ids: ["123", "456", "789"], route_id: "111", shape_id: "1110177", - shape_priority: 1, time_desc: null, typicality: 1, sort_order: 1, diff --git a/lib/dotcom_web/controllers/schedule/line/helpers.ex b/lib/dotcom_web/controllers/schedule/line/helpers.ex index e2393dffdd..8ea55faa5e 100644 --- a/lib/dotcom_web/controllers/schedule/line/helpers.ex +++ b/lib/dotcom_web/controllers/schedule/line/helpers.ex @@ -110,19 +110,12 @@ defmodule DotcomWeb.ScheduleController.Line.Helpers do @doc """ Filters a list of route patterns down to the route patterns sharing the lowest - number for the "typicality" property, additionally removing route patterns - associated with a negative shape_priority value. + number for the "typicality" property. """ @spec filtered_by_typicality([RoutePattern.t()]) :: [RoutePattern.t()] def filtered_by_typicality(route_patterns) do route_patterns |> filter_by_min_typicality() - |> Enum.filter(fn x -> - # TODO: Deprecate our use of shape priority entirely, - # because it's no longer supported in the V3 API - # For now, be less strict if using the most typical route pattern - if x.typicality == 1, do: true, else: x.shape_priority > 0 - end) end # Filters route patterns by the smallest typicality found in the array diff --git a/lib/route_patterns/route_pattern.ex b/lib/route_patterns/route_pattern.ex index c6af7449a4..b09838d822 100644 --- a/lib/route_patterns/route_pattern.ex +++ b/lib/route_patterns/route_pattern.ex @@ -26,40 +26,38 @@ defmodule RoutePatterns.RoutePattern do defstruct [ :direction_id, + :headsign, :id, :name, :representative_trip_id, :representative_trip_polyline, - :shape_id, - :shape_priority, - :headsign, - :stop_ids, :route_id, - :time_desc, - :typicality, :service_id, - :canonical, - sort_order: 0 + :shape_id, + :time_desc, + canonical: false, + sort_order: 0, + stop_ids: [], + typicality: 5 ] @type id_t :: String.t() - @type typicality_t :: 0 | 1 | 2 | 3 | 4 + @type typicality_t :: 0 | 1 | 2 | 3 | 4 | 5 @type t :: %__MODULE__{ + canonical: boolean(), direction_id: 0 | 1, id: id_t(), + headsign: String.t(), name: String.t(), representative_trip_id: Trip.id_t(), representative_trip_polyline: String.t(), + route_id: Route.id_t(), + service_id: String.t(), shape_id: String.t(), - shape_priority: number, - headsign: String.t(), + sort_order: non_neg_integer(), stop_ids: [Stop.id_t()], - route_id: Route.id_t(), time_desc: String.t(), - typicality: typicality_t(), - sort_order: integer(), - canonical: boolean(), - service_id: String.t() + typicality: typicality_t() } def new(%Item{ diff --git a/test/dotcom_web/controllers/schedule/line/helpers_test.exs b/test/dotcom_web/controllers/schedule/line/helpers_test.exs index 081494f077..178ef7f080 100644 --- a/test/dotcom_web/controllers/schedule/line/helpers_test.exs +++ b/test/dotcom_web/controllers/schedule/line/helpers_test.exs @@ -866,17 +866,6 @@ defmodule DotcomWeb.ScheduleController.Line.HelpersTest do %RoutePatterns.RoutePattern{typicality: 5} ]) end - - test "excludes route patterns with negative shape_priority" do - assert [%RoutePatterns.RoutePattern{typicality: 2, shape_priority: 1}, _] = - Helpers.filtered_by_typicality([ - %RoutePatterns.RoutePattern{typicality: 2, shape_priority: -2}, - %RoutePatterns.RoutePattern{typicality: 2, shape_priority: 1}, - %RoutePatterns.RoutePattern{typicality: 2, shape_priority: 2}, - %RoutePatterns.RoutePattern{typicality: 4, shape_priority: 1}, - %RoutePatterns.RoutePattern{typicality: 5, shape_priority: 1} - ]) - end end describe "get_stop_tree_or_lists/2" do