From 04ae84715d6b599c52a6f90585aa5c3af7439235 Mon Sep 17 00:00:00 2001 From: Krystof Date: Sun, 17 Nov 2024 00:41:36 +0100 Subject: [PATCH] feat(be): departures v2 minutesAfter --- .../src/modules/departure/departure-v2.service.ts | 3 ++- .../src/modules/departure/departure.controller.ts | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/backend/src/modules/departure/departure-v2.service.ts b/apps/backend/src/modules/departure/departure-v2.service.ts index 02f7d8e..e09cd25 100644 --- a/apps/backend/src/modules/departure/departure-v2.service.ts +++ b/apps/backend/src/modules/departure/departure-v2.service.ts @@ -23,6 +23,7 @@ export class DepartureServiceV2 { limit: number | null; totalLimit: number | null; minutesBefore: number; + minutesAfter: number; }): Promise { const vehicleTypeWhere = args.vehicleType === "metro" @@ -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), }), ), diff --git a/apps/backend/src/modules/departure/departure.controller.ts b/apps/backend/src/modules/departure/departure.controller.ts index dc4486b..33967c1 100644 --- a/apps/backend/src/modules/departure/departure.controller.ts +++ b/apps/backend/src/modules/departure/departure.controller.ts @@ -184,8 +184,7 @@ export class DepartureController { { name: "platform[]", description: "Platform IDs", - type: String, - isArray: true, + type: [String], example: ["U1040Z101P", "U1040Z102P"], allowEmptyValue: true, required: false, @@ -193,9 +192,8 @@ export class DepartureController { { name: "stop[]", description: "Stop IDs", - type: String, + type: [String], example: ["U1040"], - isArray: true, allowEmptyValue: true, required: false, }, @@ -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", @@ -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) { @@ -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);