Skip to content

Commit

Permalink
Updates for Rain and Cars By Week
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoitie committed Sep 25, 2024
1 parent e8f626a commit 324f5b5
Show file tree
Hide file tree
Showing 23 changed files with 298 additions and 394 deletions.
38 changes: 27 additions & 11 deletions build/api/getSeason.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import moment from 'moment';
import { clientGet } from './iracingClient';
import uniq from 'lodash.uniq';


const trackTypeToCatId = {
oval: 1,
Expand Down Expand Up @@ -98,17 +100,31 @@ export default async function getSeason(cars: Array<carType>, tracks: Array<trac
seriesname: series.schedules.length ? series.schedules[0].series_name.trim() : series.season_name.trim(),
start: series.start_date,
end: end.toISOString(),
tracks: series.schedules.map((week) => ({
raceweek: week.race_week_num,
config: week.track.config_name,
name: week.track.config_name ? `${week.track.track_name} - ${week.track.config_name}` : week.track.track_name,
pkgid: trackMap[week.track.track_id].pkgid,
start: week.start_date,
weekLength: week.race_time_descriptors[0]?.day_offset?.length,
race_time_descriptors: week.race_time_descriptors,
race_lap_limit: week.race_lap_limit,
race_time_limit: week.race_time_limit,
})),
tracks: series.schedules.map((week) => {
const carsForWeek = week.race_week_cars?.map((raceWeekCar) => raceWeekCar.car_id) || null;
let carsForWeekName = null;
if (carsForWeek?.length > 0) {
carsForWeekName = carClassResponse.data.find((carClass) => {
const carIds = carClass.cars_in_class.map((car) => car.car_id).sort();
return uniq(carIds).toString() === uniq(carsForWeek.sort()).toString();
})?.short_name || null;
}
return ({
raceweek: week.race_week_num,
config: week.track.config_name,
name: week.track.config_name ? `${week.track.track_name} - ${week.track.config_name}` : week.track.track_name,
pkgid: trackMap[week.track.track_id].pkgid,
start: week.start_date,
weekLength: week.race_time_descriptors[0]?.day_offset?.length,
race_time_descriptors: week.race_time_descriptors,
race_lap_limit: week.race_lap_limit,
race_time_limit: week.race_time_limit,
carsForWeek: uniq(carsForWeek.map((carId) => carMap[carId].sku)),
carsForWeekName,
carsForWeekNames: week.race_week_cars?.map((raceWeekCar) => raceWeekCar.car_name_abbreviated) || null,
precipChance: week.weather.weather_summary?.precip_chance || 0,
});
}),
catid: trackTypeToCatId[series.track_types[0].track_type],
isOfficial: series.official,
licenceGroup: series.license_group,
Expand Down
20 changes: 20 additions & 0 deletions src/components/__tests__/__snapshots__/GlobalModals.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ exports[`components/GlobalModals renders open options, closing and saving 1`] =
</label>
</div>
</div>
<div
className="col-xs-3 col-md-2"
>
<div
className="checkbox"
>
<label
htmlFor="options-columns-rain"
>
<input
checked={false}
disabled={false}
id="options-columns-rain"
onChange={[Function]}
type="checkbox"
/>
Rain
</label>
</div>
</div>
<div
className="col-xs-3 col-md-2"
>
Expand Down
28 changes: 28 additions & 0 deletions src/components/columns/Rain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow

import * as React from 'react';
import { useTranslation } from 'react-i18next';

type Props = {
race: {
precipChance: number,
},
};

export default function Rain({ race }: Props) {
const { t } = useTranslation();
let rainText = t('No');
if (race.precipChance === 100) {
rainText = t('Yes');
}
if (race.precipChance > 0) {
rainText = t('Chance');
}
return (
<td>
<div>
{rainText}
</div>
</td>
);
}
1 change: 1 addition & 0 deletions src/components/columns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export { default as LinkColumn } from './LinkColumn';
export { default as NextRace } from './NextRace';
export { default as Official } from './Official';
export { default as RaceTimes } from './RaceTimes';
export { default as Rain } from './Rain';
export { default as Series } from './Series';
export { default as SeasonEnd } from './SeasonEnd';
export { default as StartDate } from './StartDate';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/SeriesModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function SeriesModal({ onClose, ownedTracks, ownedCars, isOpen, s
},
};

const showCar = !!(offWeekData[seasonId]?.carByWeek);
const showCar = races[0].carsForWeek?.length > 0;

return (
<Modal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ exports[`components/modal/OptionsModal renders with checkbox saving 1`] = `
</label>
</div>
</div>
<div
className="col-xs-3 col-md-2"
>
<div
className="checkbox"
>
<label
htmlFor="options-columns-rain"
>
<input
checked={false}
disabled={false}
id="options-columns-rain"
onChange={[Function]}
type="checkbox"
/>
Rain
</label>
</div>
</div>
<div
className="col-xs-3 col-md-2"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
<th>
Track
</th>
<th>
Car
</th>
<th>
Start
</th>
Expand All @@ -386,11 +383,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 6, 2022
</td>
Expand Down Expand Up @@ -418,11 +410,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight Jump
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 7, 2022
</td>
Expand All @@ -446,11 +433,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 8, 2022
</td>
Expand All @@ -474,11 +456,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight Jump
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 9, 2022
</td>
Expand All @@ -502,11 +479,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 10, 2022
</td>
Expand All @@ -530,11 +502,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight Jump
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 11, 2022
</td>
Expand All @@ -558,11 +525,6 @@ exports[`components/modal/SeriesModal renders with cars 1`] = `
>
Irwindale Speedway - Figure Eight
</td>
<td
className=""
>
Rallycross, Pro 2 Truck
</td>
<td>
September 12, 2022
</td>
Expand Down
33 changes: 1 addition & 32 deletions src/data/__mocks__/offWeeks.js
Original file line number Diff line number Diff line change
@@ -1,32 +1 @@
export default {
2550: {
carByWeek: [
[10009], // 1 Skip Barber Formula 2000
[10567], // 2 Audi R8 LMS EVO II GT3
[10516], // 3 Hyundai Elantra N TC
[10232], // 4 Street Stock
[10484], // 5 Chevrolet Corvette C8.R GTE
[10497], // 6 McLaren 570S GT4
[10011], // 7 Pontiac Solstice
[10040], // 8 Radical SR8
[10552], // 9 Ligier JS P320
[10006], // 10 [Legacy] Pro Mazda
[10473], // 11 Porsche 718 Cayman GT4 Clubsport MR
[10495], // 12 Lamborghini Huracán GT3 EVO
],
carClassShortNameByWeek: [
['SBRS'], // 1 Skip Barber Formula 2000
['Audi R8 EVO2 GT3'], // 2 Audi R8 LMS EVO II GT3
['Elantra N TC'], // 3 Hyundai Elantra N TC
['Street Stock'], // 4 Street Stock
['Vette C8.R GTE'], // 5 Chevrolet Corvette C8.R GTE
['McLaren 570S GT4'], // 6 McLaren 570S GT4
['Solstice'], // 7 Pontiac Solstice
['SR8'], // 8 Radical SR8
['Ligier JS P320'], // 9 Ligier JS P320
['Pro Mazda'], // 10 [Legacy] Pro Mazda
['Porsche 718'], // 11 Porsche 718 Cayman GT4 Clubsport MR
['Lambo Huracán'], // 12 Lamborghini Huracán GT3 EVO
],
},
};
export default {};
Loading

0 comments on commit 324f5b5

Please sign in to comment.