Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Add request params (ship, take) for pagination to GET order endpoint (#2382)

shyam kachhadiyaf40f0653c2f0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 91432d8543..f31b6a80b8 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 be6a6bead4..8c8e3e27af 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<Activities> {
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 f518e0bb32..10515018cc 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