Skip to content

Commit

Permalink
fix(be): routeId in departures
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Dec 5, 2024
1 parent b9aadd3 commit 3abfd5e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions apps/backend/src/modules/departure/departure-v2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,28 @@ export class DepartureServiceV2 {
throw new Error(parsed.error.message);
}

const gtfsRoutes = await this.prisma.gtfsRoute.findMany({
where: {
shortName: {
in: parsed.data.departures.map(
(departure) => departure.route.short_name,
),
},
},
});

const parsedDepartures = parsed.data.departures.map((departure) => {
return {
id: departure.trip.id,
departure: departure.departure_timestamp,
delay: getDelayInSeconds(departure.delay),
headsign: departure.trip.headsign,
route: departure.route.short_name,
routeId:
gtfsRoutes.find(
(gtfsRoute) =>
gtfsRoute.shortName === departure.route.short_name,
)?.id ?? null,
platformId: departure.stop.id,
platformCode: departure.stop.platform_code,
};
Expand Down

1 comment on commit 3abfd5e

@vercel
Copy link

@vercel vercel bot commented on 3abfd5e Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.