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

Commuter rail in Data Dashboard #898

Draft
wants to merge 68 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
7acd7c5
Using Gobble data
devinmatte Dec 17, 2023
06fda87
Adding commuter rail data to data dashboard
devinmatte Dec 18, 2023
de039bd
Merge remote-tracking branch 'origin/main' into gobble-data
devinmatte Dec 18, 2023
a378dc4
Merge branch 'main' into gobble-data
devinmatte Dec 20, 2023
f361981
Merge branch 'main' into gobble-data
devinmatte Dec 20, 2023
74ce70a
Treat bus the same as rapid for dates
devinmatte Dec 20, 2023
02cb728
Merge branch 'main' into commuter-rail-in-dd
devinmatte Dec 21, 2023
75c60ab
Better if statement
devinmatte Dec 22, 2023
aa40939
Handle date formats with timezones
devinmatte Dec 22, 2023
30ddd1f
Renaming date_utils
devinmatte Dec 22, 2023
a122a88
Cleanup imports
devinmatte Dec 22, 2023
6751998
Merge branch 'main' into gobble-data
devinmatte Dec 22, 2023
9532a70
Inject timezone into non-timezone datestamps
devinmatte Dec 22, 2023
5bb67e6
Merge branch 'gobble-data' into commuter-rail-in-dd
devinmatte Dec 22, 2023
ee77537
Set minimum commuter rail date
devinmatte Dec 22, 2023
4577978
Adding some initial platform ids
devinmatte Dec 22, 2023
d137236
Adding lowell line platform ids
devinmatte Dec 22, 2023
20c5eec
Properly fetching CR stations
devinmatte Dec 22, 2023
3a89a12
Acutally fetching CR data
devinmatte Dec 23, 2023
a8ed493
Adding franklin line ids
devinmatte Dec 23, 2023
94b1f5a
Populating stations
devinmatte Dec 23, 2023
b23874e
Adding more lines
devinmatte Dec 26, 2023
90443ff
Adding Haverhill stops
devinmatte Dec 26, 2023
43db5e0
Updating min dates
devinmatte Dec 26, 2023
772d10e
Adding more lines and better stop population
devinmatte Dec 26, 2023
8552827
Clean up scripts
devinmatte Dec 26, 2023
5917d97
Allowing commuter rail ridership fetching
devinmatte Dec 27, 2023
abb331c
Merge branch 'main' into commuter-rail-in-dd
devinmatte Dec 27, 2023
e17b392
Updating line files
devinmatte Dec 27, 2023
4f3f337
Adding more stop ids
devinmatte Dec 27, 2023
d223d02
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 1, 2024
8de71df
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 8, 2024
6a42b6d
Fixing bus typing
devinmatte Jan 8, 2024
078206f
Merge remote-tracking branch 'origin/main' into commuter-rail-in-dd
devinmatte Jan 9, 2024
7e4505f
Remove foxboro for now
devinmatte Jan 9, 2024
b69f386
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 11, 2024
b169555
Merge remote-tracking branch 'origin/main' into commuter-rail-in-dd
devinmatte Jan 11, 2024
8db9c46
Fix widget title import
devinmatte Jan 11, 2024
a094889
Merge remote-tracking branch 'origin/main' into commuter-rail-in-dd
devinmatte Jan 17, 2024
3b102e1
Updating CR line files
devinmatte Jan 17, 2024
d5913dd
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 20, 2024
35c5410
Hide stations we don't have stops for
devinmatte Jan 21, 2024
3101977
Nevermind
devinmatte Jan 21, 2024
c27a83e
Populate with newer stops
devinmatte Jan 21, 2024
93b5197
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 23, 2024
8b40dc5
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jan 30, 2024
631a5f0
Fixing CR data calls
devinmatte Feb 4, 2024
144a6f2
Merge branch 'main' into commuter-rail-in-dd
devinmatte Feb 10, 2024
6d6da82
Merge branch 'main' into commuter-rail-in-dd
devinmatte Feb 14, 2024
f722dde
Merge branch 'main' into commuter-rail-in-dd
devinmatte Feb 25, 2024
ef4c548
Merge branch 'main' into commuter-rail-in-dd
devinmatte Mar 9, 2024
8fb44d1
Fixing 120+ minute headways for CR
devinmatte Mar 10, 2024
634b983
Updating commuter rail stations and notices
devinmatte Mar 11, 2024
4810c36
Merge remote-tracking branch 'origin/main' into commuter-rail-in-dd
devinmatte May 17, 2024
7ce77b4
Fixing data fetching issues for cr
devinmatte May 17, 2024
d837b4c
Remove unused
devinmatte May 17, 2024
3b34d1b
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jun 18, 2024
e281387
Merge branch 'main' into commuter-rail-in-dd
devinmatte Jul 18, 2024
5ed4575
Adding commuter rail ridership to dashboard
devinmatte Jul 19, 2024
0272985
Fixing props
devinmatte Jul 19, 2024
6af58db
Adding commuter rail landing button
devinmatte Jul 19, 2024
0285525
Merge branch 'commuter-rail-ridership' into commuter-rail-in-dd
devinmatte Jul 19, 2024
c23d10f
Fixing commuter rail links
devinmatte Jul 19, 2024
cabcc80
Fix linting issues
devinmatte Jul 19, 2024
8389487
Merge remote-tracking branch 'origin/main' into commuter-rail-in-dd
devinmatte Jul 29, 2024
8b17144
Adding log retention policy
devinmatte Aug 1, 2024
3742ac3
Oops we'd need to delete the stack
devinmatte Aug 1, 2024
385f905
Okay nevermind
devinmatte Aug 1, 2024
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
12 changes: 9 additions & 3 deletions common/components/controls/ControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import React from 'react';
import classNames from 'classnames';
import { lineColorBorder } from '../../styles/general';
import type { BusRoute, Line } from '../../types/lines';
import type { BusRoute, CommuterRailRoute, Line } from '../../types/lines';
import type { DateStoreSection } from '../../constants/pages';
import { StationSelectorWidget } from '../widgets/StationSelectorWidget';
import { DateControl } from './DateControl';

interface ControlPanelProps {
dateStoreSection: DateStoreSection;
busRoute: BusRoute | undefined;
crRoute: CommuterRailRoute | undefined;
line: Line | undefined;
}

export const ControlPanel: React.FC<ControlPanelProps> = ({ dateStoreSection, line, busRoute }) => {
export const ControlPanel: React.FC<ControlPanelProps> = ({
dateStoreSection,
line,
busRoute,
crRoute,
}) => {
const getControls = () => {
if ((dateStoreSection === 'singleTrips' || dateStoreSection === 'multiTrips') && line) {
return (
Expand All @@ -21,7 +27,7 @@ export const ControlPanel: React.FC<ControlPanelProps> = ({ dateStoreSection, li
dateStoreSection={dateStoreSection}
queryType={dateStoreSection === 'singleTrips' ? 'single' : 'range'}
/>
<StationSelectorWidget line={line} busRoute={busRoute} />
<StationSelectorWidget line={line} busRoute={busRoute} crRoute={crRoute} />
</>
);
}
Expand Down
6 changes: 4 additions & 2 deletions common/components/controls/MobileControlPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import type { BusRoute, Line } from '../../types/lines';
import type { BusRoute, CommuterRailRoute, Line } from '../../types/lines';
import type { DateStoreSection } from '../../constants/pages';
import { lineColorBackground } from '../../styles/general';
import { StationSelectorWidget } from '../widgets/StationSelectorWidget';
Expand All @@ -9,13 +9,15 @@ import { DateControl } from './DateControl';
interface MobileControlPanelProps {
dateStoreSection: DateStoreSection;
busRoute: BusRoute | undefined;
crRoute: CommuterRailRoute | undefined;
line: Line | undefined;
}

export const MobileControlPanel: React.FC<MobileControlPanelProps> = ({
dateStoreSection,
line,
busRoute,
crRoute,
}) => {
const singleDate = dateStoreSection === 'singleTrips';
const getControls = () => {
Expand All @@ -34,7 +36,7 @@ export const MobileControlPanel: React.FC<MobileControlPanelProps> = ({
lineColorBackground[line ?? 'DEFAULT']
)}
>
<StationSelectorWidget line={line} busRoute={busRoute} />
<StationSelectorWidget line={line} busRoute={busRoute} crRoute={crRoute} />
</div>
</>
);
Expand Down
5 changes: 3 additions & 2 deletions common/components/inputs/StationSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ export const StationSelector: React.FC<StationSelector> = ({
const {
line,
lineShort,
query: { busRoute },
query: { busRoute, crRoute },
} = useDelimitatedRoute();
const mdBreakpoint = useBreakpoint('md');
const station = type === 'from' ? fromStation : toStation;
const stationOptions = optionsForField(type, lineShort, fromStation, busRoute);
const stationOptions = optionsForField(type, lineShort, fromStation, busRoute, crRoute);
const branchLabelWidth = {
'line-red': 'w-8',
'line-green': 'w-12',
DEFAULT: 'w-0',
};

return (
<Listbox value={station} onChange={setStation}>
{({ open }) => (
Expand Down
8 changes: 3 additions & 5 deletions common/components/nav/CommuterRailDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { SidebarTabs } from '../../../modules/navigation/SidebarTabs';
import { COMMUTER_RAIL_OVERVIEW } from '../../constants/pages';
import { COMMUTER_RAIL_OVERVIEW, TRIP_PAGES } from '../../constants/pages';
import { CommuterRailRouteSelection } from './CommuterRailRouteSelection';

interface CommuterRailDropdownProps {
Expand All @@ -18,10 +18,8 @@ export const CommuterRailDropdown: React.FC<CommuterRailDropdownProps> = ({ clos
role={'navigation'}
>
<SidebarTabs tabs={COMMUTER_RAIL_OVERVIEW} close={close} />

{/* TODO: Once we have reliable travel data for CR */}
{/* <hr className="h-[1px] w-3/4 self-center border-neutral-500" /> */}
{/* <SidebarTabs tabs={TRIP_PAGES} close={close} /> */}
<hr className="h-[1px] w-3/4 self-center border-neutral-500" />
<SidebarTabs tabs={TRIP_PAGES} close={close} />
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion common/components/nav/MenuDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const MenuDropdown: React.FC<MenuDropdownProps> = ({ line, route, childre
case 'line-bus':
return `/bus/trips/single?busRoute=1&date=${BUS_DEFAULTS.singleTripConfig.date}`;
case 'line-commuter-rail':
return `/commuter-rail/ridership?crRoute=CR-Lowell&startDate=${COMMUTER_RAIL_DEFAULTS.lineConfig.startDate}&endDate=${COMMUTER_RAIL_DEFAULTS.lineConfig.endDate}`;
return `/commuter-rail/trips/single?crRoute=CR-Lowell&date=${COMMUTER_RAIL_DEFAULTS.singleTripConfig.date}`;
default:
return getLineSelectionItemHref(line, route);
}
Expand Down
11 changes: 8 additions & 3 deletions common/components/widgets/StationSelectorWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@ import {
optionsStation,
stopIdsForStations,
} from '../../utils/stations';
import type { BusRoute, Line } from '../../types/lines';
import type { BusRoute, CommuterRailRoute, Line } from '../../types/lines';
import { LINE_OBJECTS } from '../../constants/lines';
import type { Station } from '../../types/stations';

interface StationSelectorWidgetProps {
line: Line;
busRoute: BusRoute | undefined;
crRoute: CommuterRailRoute | undefined;
}

export const StationSelectorWidget: React.FC<StationSelectorWidgetProps> = ({ line, busRoute }) => {
export const StationSelectorWidget: React.FC<StationSelectorWidgetProps> = ({
line,
busRoute,
crRoute,
}) => {
const updateQueryParams = useUpdateQuery();
const lineShort = LINE_OBJECTS[line].short;
const {
query: { from, to },
} = useDelimitatedRoute();

const stations = optionsStation(lineShort, busRoute);
const stations = optionsStation(lineShort, busRoute, crRoute);
const toStation = to ? getParentStationForStopId(to) : stations?.[stations.length - 2];
const fromStation = from ? getParentStationForStopId(from) : stations?.[1];
React.useEffect(() => {
Expand Down
109 changes: 109 additions & 0 deletions common/constants/cr_constants/cr-fairmount.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"CR-Fairmount": {
"type": "commuter-rail",
"direction": {
"0": "outbound",
"1": "inbound"
},
"stations": [
{
"stop_name": "Readville",
"station": "place-DB-0095",
"branches": null,
"order": 1,
"stops": {
"0": [],
"1": ["CR-Fairmount_1_FB-0095-04"]
},
"terminus": true
},
{
"stop_name": "Fairmount",
"station": "place-DB-2205",
"branches": null,
"order": 2,
"stops": {
"0": ["CR-Fairmount_0_DB-2205-01"],
"1": ["CR-Fairmount_1_DB-2205-02"]
}
},
{
"stop_name": "Blue Hill Avenue",
"station": "place-DB-2222",
"branches": null,
"order": 3,
"stops": {
"0": ["CR-Fairmount_0_DB-2222-01"],
"1": ["CR-Fairmount_1_DB-2222-02"]
}
},
{
"stop_name": "Morton Street",
"station": "place-DB-2230",
"branches": null,
"order": 4,
"stops": {
"0": ["CR-Fairmount_0_DB-2230-01"],
"1": ["CR-Fairmount_1_DB-2230-02"]
}
},
{
"stop_name": "Talbot Avenue",
"station": "place-DB-2240",
"branches": null,
"order": 5,
"stops": {
"0": ["CR-Fairmount_0_DB-2240-01"],
"1": ["CR-Fairmount_1_DB-2240-02"]
}
},
{
"stop_name": "Four Corners/Geneva",
"station": "place-DB-2249",
"branches": null,
"order": 6,
"stops": {
"0": ["CR-Fairmount_0_DB-2249-01"],
"1": ["CR-Fairmount_1_DB-2249-02"]
}
},
{
"stop_name": "Uphams Corner",
"station": "place-DB-2258",
"branches": null,
"order": 7,
"stops": {
"0": ["CR-Fairmount_0_DB-2258-01"],
"1": ["CR-Fairmount_1_DB-2258-02"]
}
},
{
"stop_name": "Newmarket",
"station": "place-DB-2265",
"branches": null,
"order": 8,
"stops": {
"0": ["CR-Fairmount_0_DB-2265-01"],
"1": ["CR-Fairmount_1_DB-2265-02"]
}
},
{
"stop_name": "South Station",
"station": "place-sstat",
"branches": null,
"order": 9,
"stops": {
"0": [
"CR-Fairmount_0_NEC-2287-09",
"CR-Fairmount_0_NEC-2287-11",
"CR-Fairmount_0_NEC-2287-10",
"CR-Fairmount_0_NEC-2287-07",
"CR-Fairmount_0_NEC-2287"
],
"1": []
},
"terminus": true
}
]
}
}
Loading
Loading