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

feat: Add Green Line Slow Zones #1017

Merged
merged 16 commits into from
Jan 18, 2025
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
11 changes: 2 additions & 9 deletions common/components/nav/SubwayDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames';
import React from 'react';
import { SidebarTabs } from '../../../modules/navigation/SidebarTabs';
import { OVERVIEW_PAGE, LINE_PAGES, TRIP_PAGES, ALL_PAGES } from '../../constants/pages';
import { OVERVIEW_PAGE, LINE_PAGES, TRIP_PAGES } from '../../constants/pages';
import { lineColorBorder } from '../../styles/general';
import type { Line } from '../../types/lines';

Expand All @@ -21,14 +21,7 @@ export const SubwayDropdown: React.FC<SubwayDropdownProps> = ({ line, close }) =
>
<SidebarTabs tabs={OVERVIEW_PAGE} close={close} />
<hr className="h-[1px] w-3/4 self-center border-neutral-500" />
<SidebarTabs
tabs={
line === 'line-green'
? LINE_PAGES.filter((cur) => cur !== ALL_PAGES.slowzones)
: LINE_PAGES
}
close={close}
/>
<SidebarTabs tabs={LINE_PAGES} close={close} />
<hr className="h-[1px] w-3/4 self-center border-neutral-500" />
<SidebarTabs tabs={TRIP_PAGES} close={close} />
</div>
Expand Down
29 changes: 29 additions & 0 deletions common/components/notices/BetaSlowZoneDataNotice.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ExclamationTriangleIcon } from '@heroicons/react/20/solid';
import React from 'react';

export const BetaSlowZoneDataNotice: React.FC = () => {
return (
<div className="rounded-md bg-yellow-50 p-4">
<div className="flex">
<div className="flex-shrink-0">
<ExclamationTriangleIcon className="h-5 w-5 text-yellow-400" aria-hidden="true" />
</div>
<div className="ml-3">
<h3 className="text-sm font-medium text-yellow-800">Green Line Slow Zones are in Beta</h3>
<div className="mt-2 text-sm text-yellow-700">
<p>
Due to the variable nature of service on the Green Line, we aren't able to detect slow
zones as easily as on the heavy rail lines. Additionaly, we are only monitoring slow
zones for stops serviced by the D line since that is the only line which is entirely
grade-separated.
</p>
<p>
We're working on improving the data and we plan to add slow-zone tracking for other
branches, but that will require additional information on traffic patterns.
</p>
</div>
</div>
</div>
</div>
);
};
2 changes: 1 addition & 1 deletion common/constants/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const ALL_PAGES: PageMap = {
key: 'slowzones',
path: '/slowzones',
name: 'Slow zones',
lines: ['line-red', 'line-blue', 'line-orange'],
lines: ['line-red', 'line-blue', 'line-orange', 'line-green'],
icon: faWarning,
dateStoreSection: 'line',
},
Expand Down
5 changes: 1 addition & 4 deletions modules/dashboard/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ServiceWidget } from '../service/ServiceWidget';
import { PageWrapper } from '../../common/layouts/PageWrapper';
import { Layout } from '../../common/layouts/layoutTypes';
import { RidershipWidget } from '../ridership/RidershipWidget';
import { HEAVY_RAIL_LINES } from '../../common/types/lines';
import { useRewriteV3Route } from '../../common/utils/middleware';
import { LINE_OBJECTS } from '../../common/constants/lines';
import { AlertsWidget } from '../alerts/AlertsWidget';
Expand All @@ -16,8 +15,6 @@ export function Overview() {

useRewriteV3Route();

const isHeavyRailLine = line ? HEAVY_RAIL_LINES.includes(line) : false;

const lineShort = line && line !== 'line-bus' ? LINE_OBJECTS[line].short : null;

return (
Expand All @@ -26,7 +23,7 @@ export function Overview() {
{tab === 'Subway' && <SpeedWidget />}
{tab === 'Subway' && <ServiceWidget />}
<RidershipWidget />
{tab === 'Subway' && isHeavyRailLine && <SlowZonesWidget />}
{tab === 'Subway' && <SlowZonesWidget />}
<div className="grid w-full grid-cols-1 gap-4 md:gap-8 xl:col-span-2 xl:grid-cols-2">
{tab === 'Subway' && lineShort && <AlertsWidget lineShort={lineShort} />}
</div>
Expand Down
5 changes: 4 additions & 1 deletion modules/slowzones/SlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { PageWrapper } from '../../common/layouts/PageWrapper';
import { ChartPageDiv } from '../../common/components/charts/ChartPageDiv';
import { Layout } from '../../common/layouts/layoutTypes';
import { useBreakpoint } from '../../common/hooks/useBreakpoint';
import { BetaSlowZoneDataNotice } from '../../common/components/notices/BetaSlowZoneDataNotice';
import { SlowZonesSegmentsWrapper } from './SlowZonesSegmentsWrapper';
import { TotalSlowTimeWrapper } from './TotalSlowTimeWrapper';
import { SlowZonesMap } from './map';
Expand Down Expand Up @@ -48,7 +49,8 @@ export function SlowZonesDetails() {
const totalSlowTimeReady =
!delayTotals.isError && delayTotals.data && startDateUTC && endDateUTC && lineShort && line;
const segmentsReady = !allSlow.isError && allSlow.data && startDateUTC && lineShort;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

if (!endDateUTC || !startDateUTC) {
Expand All @@ -62,6 +64,7 @@ export function SlowZonesDetails() {
return (
<PageWrapper pageTitle={'Slow zones'}>
<ChartPageDiv>
<BetaSlowZoneDataNotice />
<WidgetDiv>
<WidgetTitle title="Total slow time" />
<Link
Expand Down
2 changes: 1 addition & 1 deletion modules/slowzones/SlowZonesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const SlowZonesWidget: React.FC = () => {
const totalSlowTimeReady =
!delayTotals.isError && delayTotals.data && startDateUTC && endDateUTC && lineShort && line;

if (line === 'line-bus' || line === 'line-green' || line === 'line-commuter-rail') {
if (line === 'line-bus' || line === 'line-commuter-rail') {
return null;
}

Expand Down
4 changes: 3 additions & 1 deletion modules/slowzones/SystemSlowZonesDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet

const [lineShort, setLineShort] = useState<LineShort>('Red');
const line = `line-${lineShort.toLowerCase()}` as Line;
const canShowSlowZonesMap = lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange';
const canShowSlowZonesMap =
lineShort === 'Red' || lineShort === 'Blue' || lineShort === 'Orange' || lineShort === 'Green';
const isDesktop = useBreakpoint('lg');

const {
Expand Down Expand Up @@ -116,6 +117,7 @@ export function SystemSlowZonesDetails({ showTitle = false }: SystemSlowZonesDet
Red: 'Red',
Orange: 'Orange',
Blue: 'Blue',
Green: 'Green',
})}
/>
</WidgetDiv>
Expand Down
8 changes: 8 additions & 0 deletions modules/slowzones/charts/TotalSlowTime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export const TotalSlowTime: React.FC<TotalSlowTimeProps> = ({
pointRadius: 0,
tension: 0.1,
},
{
label: `Green Line`,
data: data?.map((d) => (d['Green'] / 60).toFixed(2)),
borderColor: LINE_COLORS['line-green'],
backgroundColor: LINE_COLORS['line-green'],
pointRadius: 0,
tension: 0.1,
},
];
return (
<ChartBorder>
Expand Down
13 changes: 13 additions & 0 deletions modules/slowzones/map/SlowZonesMap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@ export const Primary = () => {
direction="vertical"
speedRestrictions={[]}
/>

<SlowZonesMap
lineName="Green"
slowZones={slowZonesResponses}
direction="vertical"
speedRestrictions={[]}
/>
<SlowZonesMap
lineName="Green"
slowZones={slowZonesResponses}
direction="horizontal"
speedRestrictions={[]}
/>
</>
);
};
2 changes: 1 addition & 1 deletion modules/slowzones/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange'] as const;
const SLOW_ZONES_LINES = ['Red', 'Blue', 'Orange', 'Green'] as const;

export type SlowZonesLineName = (typeof SLOW_ZONES_LINES)[number];
Loading
Loading