From f40f0653c2f0b18ff2aac89a1e076e000f4460f8 Mon Sep 17 00:00:00 2001 From: shyam kachhadiya <39761970+shyam1s15@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:24:21 +0530 Subject: [PATCH] Add request params (ship, take) for pagination to GET order endpoint (#2382) * Add request params (ship, take) for pagination to GET order endpoint * Update changelog --- CHANGELOG.md | 4 ++++ apps/api/src/app/order/order.controller.ts | 6 +++++- apps/api/src/app/order/order.service.ts | 6 ++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91432d854..f31b6a80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added pagination parameters (`skip`, `take`) to the endpoint `GET api/v1/order` + ### Fixed - Fixed the sidebar navigation on the user account page diff --git a/apps/api/src/app/order/order.controller.ts b/apps/api/src/app/order/order.controller.ts index be6a6bead..8c8e3e27a 100644 --- a/apps/api/src/app/order/order.controller.ts +++ b/apps/api/src/app/order/order.controller.ts @@ -89,7 +89,9 @@ export class OrderController { @Headers(HEADER_KEY_IMPERSONATION.toLowerCase()) impersonationId, @Query('accounts') filterByAccounts?: string, @Query('assetClasses') filterByAssetClasses?: string, - @Query('tags') filterByTags?: string + @Query('skip') skip?: number, + @Query('tags') filterByTags?: string, + @Query('take') take?: number ): Promise { const filters = this.apiService.buildFiltersFromQueryParams({ filterByAccounts, @@ -105,6 +107,8 @@ export class OrderController { filters, userCurrency, includeDrafts: true, + skip: isNaN(skip) ? undefined : skip, + take: isNaN(take) ? undefined : take, userId: impersonationUserId || this.request.user.id, withExcludedAccounts: true }); diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts index f518e0bb3..10515018c 100644 --- a/apps/api/src/app/order/order.service.ts +++ b/apps/api/src/app/order/order.service.ts @@ -230,6 +230,8 @@ export class OrderService { public async getOrders({ filters, includeDrafts = false, + skip, + take = Number.MAX_SAFE_INTEGER, types, userCurrency, userId, @@ -237,6 +239,8 @@ export class OrderService { }: { filters?: Filter[]; includeDrafts?: boolean; + skip?: number; + take?: number; types?: TypeOfOrder[]; userCurrency: string; userId: string; @@ -315,6 +319,8 @@ export class OrderService { return ( await this.orders({ + skip, + take, where, include: { // eslint-disable-next-line @typescript-eslint/naming-convention