Skip to content

Commit

Permalink
Merge branch 'main' into preston/typos
Browse files Browse the repository at this point in the history
  • Loading branch information
devinmatte authored May 16, 2024
2 parents a026d38 + f2a9553 commit 174bcd6
Show file tree
Hide file tree
Showing 52 changed files with 13,653 additions and 23,942 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
node-version: ['20']
python-version: ['3.11']
python-version: ['3.12']
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
strategy:
matrix:
node-version: ['20']
python-version: ['3.11']
python-version: ['3.12']
env:
AWS_PROFILE: transitmatters
AWS_DEFAULT_REGION: us-east-1
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TM_FRONTEND_CERT_ARN: ${{ secrets.TM_FRONTEND_CERT_ARN }}
TM_LABS_WILDCARD_CERT_ARN: ${{ secrets.TM_LABS_WILDCARD_CERT_ARN }}
MBTA_V2_API_KEY: ${{ secrets.MBTA_V2_API_KEY }}
MBTA_V3_API_KEY: ${{ secrets.MBTA_V3_API_KEY }}
DD_API_KEY: ${{ secrets.DD_API_KEY }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
node-version: ['20']
python-version: ['3.11']
python-version: ['3.12']
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand All @@ -38,7 +38,7 @@ jobs:
strategy:
matrix:
node-version: ['20']
python-version: ['3.11']
python-version: ['3.12']
steps:
- name: Checkout repo
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.11.6
3.12.2
10 changes: 6 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
]
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"ms-python.black-formatter",
"ms-python.flake8"
]
}
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ This is the repository for the TransitMatters Data Dashboard. Client code is wri
- node 20.x and npm 9.x+ required
- With `nvm` installed, use `nvm install && nvm use`
- verify with `node -v`
- Python 3.11 with recent poetry (1.6.0 or later)
- Python 3.12 with recent poetry (1.7.0 or later)
- Verify with `python --version && poetry --version`
- `poetry self update` to update poetry

## Development Instructions

1. Add `MBTA_V2_API_KEY` and `MBTA_V3_API_KEY` to your shell environment:
- `export MBTA_V2_API_KEY='KEY'` in ~/.bashrc or ~/.zshrc
1. Add `MBTA_V3_API_KEY` to your shell environment:
- `export MBTA_V3_API_KEY='KEY'` in ~/.bashrc or ~/.zshrc
2. Add your AWS credentials (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY) to your shell environment, OR add them to a .boto config file with awscli command `aws configure`.
3. In the root directory, run `npm install` to install all frontend and backend dependencies
Expand Down
22 changes: 12 additions & 10 deletions common/api/hooks/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,29 @@ export const useHistoricalAlertsData = (
line: LineShort,
busRoute?: string
) => {
return useQuery(
['alerts', date, line, busRoute],
() => fetchHistoricalAlerts(date, line, busRoute),
{
staleTime: FIVE_MINUTES,
enabled: date !== undefined,
}
);
return useQuery({
queryKey: ['alerts', date, line, busRoute],
queryFn: () => fetchHistoricalAlerts(date, line, busRoute),
staleTime: FIVE_MINUTES,
enabled: date !== undefined,
});
};

export const useAlertsData = (
line: LineShort,
busRoute?: string
): UseQueryResult<AlertsResponse[]> => {
return useQuery(['alerts', line, busRoute], () => fetchAlerts(line, busRoute), {
return useQuery({
queryKey: ['alerts', line, busRoute],
queryFn: () => fetchAlerts(line, busRoute),
staleTime: ONE_MINUTE,
});
};

export const useAccessibilityAlertsData = (line: LineShort) => {
return useQuery(['accessibilityAlerts', line], () => fetchAccessibilityAlertsForLine(line), {
return useQuery({
queryKey: ['accessibilityAlerts', line],
queryFn: () => fetchAccessibilityAlertsForLine(line),
staleTime: ONE_MINUTE,
});
};
7 changes: 0 additions & 7 deletions common/api/hooks/facilities.ts

This file was deleted.

4 changes: 3 additions & 1 deletion common/api/hooks/predictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { fetchPredictions } from '../predictions';
import type { FetchPredictionsParams } from '../../types/api';

export const usePredictionData = (params: FetchPredictionsParams, enabled: boolean = true) => {
return useQuery(['predictions', params], () => fetchPredictions(params), {
return useQuery({
queryKey: ['predictions', params],
queryFn: () => fetchPredictions(params),
enabled: enabled,
staleTime: ONE_HOUR,
});
Expand Down
6 changes: 4 additions & 2 deletions common/api/hooks/ridership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import { fetchLandingRidership, fetchRidership } from '../ridership';
import { ONE_HOUR } from '../../constants/time';

export const useRidershipData = (options: FetchRidershipOptions, enabled?: boolean) => {
return useQuery(['trips', options], () => fetchRidership(options), {
return useQuery({
queryKey: ['trips', options],
queryFn: () => fetchRidership(options),
enabled: enabled,
staleTime: ONE_HOUR,
});
};

export const useRidershipDataLanding = () => {
return useQuery(['ridership-landing'], () => fetchLandingRidership());
return useQuery({ queryKey: ['ridership-landing'], queryFn: () => fetchLandingRidership() });
};
8 changes: 6 additions & 2 deletions common/api/hooks/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ import { ONE_HOUR } from '../../constants/time';
import { fetchScheduledService, fetchServiceHours } from '../service';

export const useScheduledService = (options: FetchScheduledServiceOptions, enabled?: boolean) => {
return useQuery(['scheduledservice', options], () => fetchScheduledService(options), {
return useQuery({
queryKey: ['scheduledservice', options],
queryFn: () => fetchScheduledService(options),
enabled: enabled,
staleTime: ONE_HOUR,
});
};

export const useServiceHours = (params: FetchServiceHoursOptions, enabled?: boolean) => {
return useQuery(['service_hours', params], () => fetchServiceHours(params), {
return useQuery({
queryKey: ['service_hours', params],
queryFn: () => fetchServiceHours(params),
enabled: enabled,
staleTime: 0,
});
Expand Down
8 changes: 5 additions & 3 deletions common/api/hooks/slowzones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import { ONE_HOUR } from '../../constants/time';
import type { FetchSpeedRestrictionsOptions } from '../../types/api';

export const useSlowzoneAllData = () => {
return useQuery(['allSlow'], fetchAllSlow, { staleTime: ONE_HOUR });
return useQuery({ queryKey: ['allSlow'], queryFn: fetchAllSlow, staleTime: ONE_HOUR });
};

export const useSlowzoneDelayTotalData = () => {
return useQuery(['delayTotals'], fetchDelayTotals, { staleTime: ONE_HOUR });
return useQuery({ queryKey: ['delayTotals'], queryFn: fetchDelayTotals, staleTime: ONE_HOUR });
};

export const useSpeedRestrictionData = (options: FetchSpeedRestrictionsOptions) => {
return useQuery(['speedRestrictions', options], () => fetchSpeedRestrictions(options), {
return useQuery({
queryKey: ['speedRestrictions', options],
queryFn: () => fetchSpeedRestrictions(options),
enabled: options.date !== undefined,
staleTime: ONE_HOUR,
});
Expand Down
4 changes: 3 additions & 1 deletion common/api/hooks/speed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import type { FetchSpeedsOptions } from '../../types/api';
import { FIVE_MINUTES } from '../../constants/time';

export const useSpeedData = (options: FetchSpeedsOptions, enabled?: boolean) => {
return useQuery(['speed', options], () => fetchSpeeds(options), {
return useQuery({
queryKey: ['speed', options],
queryFn: () => fetchSpeeds(options),
enabled: enabled,
staleTime: FIVE_MINUTES,
});
Expand Down
6 changes: 4 additions & 2 deletions common/api/hooks/tripmetrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ export const useDeliveredTripMetrics = (
options: FetchDeliveredTripMetricsOptions,
enabled?: boolean
) => {
return useQuery(['actualTrips', options], () => fetchActualTripsByLine(options), {
return useQuery({
queryKey: ['actualTrips', options],
queryFn: () => fetchActualTripsByLine(options),
enabled: enabled,
staleTime: FIVE_MINUTES,
});
};

export const useTripMetricsForLanding = () => {
return useQuery(['landingTrips'], () => fetchLandingTripMetrics());
return useQuery({ queryKey: ['landingTrips'], queryFn: () => fetchLandingTripMetrics() });
};
16 changes: 10 additions & 6 deletions common/components/charts/Legend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Disclosure } from '@headlessui/react';
import React from 'react';

export const LegendSingleDay: React.FC = () => {
interface LegendProps {
showUnderRatio?: boolean;
}

export const LegendSingleDay: React.FC<LegendProps> = ({ showUnderRatio = false }) => {
return (
<Disclosure>
{({ open }) => (
Expand All @@ -19,15 +23,15 @@ export const LegendSingleDay: React.FC = () => {
'grid w-full grid-cols-2 items-baseline p-1 px-4 text-left text-xs lg:flex lg:flex-row lg:gap-4'
}
>
<LegendSingle />
<LegendSingle showUnderRatio={showUnderRatio} />
</Disclosure.Panel>
</div>
)}
</Disclosure>
);
};

const LegendSingle: React.FC = () => {
const LegendSingle: React.FC<LegendProps> = ({ showUnderRatio = false }) => {

Check warning on line 34 in common/components/charts/Legend.tsx

View workflow job for this annotation

GitHub Actions / frontend (20, 3.12)

'showUnderRatio' is assigned a value but never used
return (
<>
<div className="col-span-2 flex flex-row items-baseline gap-2 pb-1 italic lg:pb-0">
Expand All @@ -43,19 +47,19 @@ const LegendSingle: React.FC = () => {
</p>
<p>
<span className="mr-1 inline-block h-2.5 w-2.5 rounded-full border border-[#D9D31E] bg-[#f5ed00]"></span>
{'25%+ above'}
{'25%+ off'}
</p>
<p>
<span
className={`mr-1 inline-block h-2.5 w-2.5 rounded-full border border-[#A1384A] bg-[#c33149]`}
></span>{' '}
{'50%+ above'}
{'50%+ off'}
</p>
<p>
<span
className={`mr-1 inline-block h-2.5 w-2.5 rounded-full border border-[#925396] bg-[#bb5cc1]`}
></span>{' '}
{'100%+ above'}
{'100%+ off'}
</p>
</>
);
Expand Down
Loading

0 comments on commit 174bcd6

Please sign in to comment.