Skip to content

Commit

Permalink
feat(be): departures v2 minutesAfter
Browse files Browse the repository at this point in the history
  • Loading branch information
krystxf committed Nov 16, 2024
1 parent 0a3522e commit 04ae847
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion apps/backend/src/modules/departure/departure-v2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class DepartureServiceV2 {
limit: number | null;
totalLimit: number | null;
minutesBefore: number;
minutesAfter: number;
}): Promise<DepartureSchema[]> {
const vehicleTypeWhere =
args.vehicleType === "metro"
Expand Down Expand Up @@ -71,7 +72,7 @@ export class DepartureServiceV2 {
mode: "departures",
order: "real",
minutesBefore: String(args.minutesBefore),
minutesAfter: String(10 * 60),
minutesAfter: String(args.minutesAfter),
limit: String(args.totalLimit ?? 1_000),
}),
),
Expand Down
15 changes: 11 additions & 4 deletions apps/backend/src/modules/departure/departure.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,16 @@ export class DepartureController {
{
name: "platform[]",
description: "Platform IDs",
type: String,
isArray: true,
type: [String],
example: ["U1040Z101P", "U1040Z102P"],
allowEmptyValue: true,
required: false,
},
{
name: "stop[]",
description: "Stop IDs",
type: String,
type: [String],
example: ["U1040"],
isArray: true,
allowEmptyValue: true,
required: false,
},
Expand Down Expand Up @@ -227,6 +225,13 @@ export class DepartureController {
example: 0,
required: false,
},
{
name: "minutesAfter",
description: "Minutes After",
type: "integer",
example: 2 * 60,
required: false,
},
{
name: "limit",
description: "Limit of results per platform and route",
Expand Down Expand Up @@ -260,6 +265,7 @@ export class DepartureController {
.nullable()
.default(null), // total limit of results (departures)
minutesBefore: z.coerce.number().optional().nullable().default(0),
minutesAfter: z.coerce.number().optional().nullable().default(null),
});
const parsed = schema.safeParse(query);
if (!parsed.success) {
Expand All @@ -285,6 +291,7 @@ export class DepartureController {
limit: parsedQuery.limit ?? null,
totalLimit: parsedQuery.totalLimit ?? null,
minutesBefore: parsedQuery.minutesBefore ?? 0,
minutesAfter: parsedQuery.minutesAfter ?? 2 * 60,
});

departureSchema.array().parse(departures);
Expand Down

0 comments on commit 04ae847

Please sign in to comment.