Skip to content

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

Bugfix/fix pagination issue in activities endpoint by adding secondary sort criterion (#3554)

Thomas Kaul744dc51dcd5b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b2320e41f1..408708fea5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Fixed
+
+- Fixed a pagination issue in the activities endpoint by adding `id` as a secondary sort criterion to `date` to ensure consistent ordering
+
## 2.93.0 - 2024-07-07
### Added
diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index a1fa4db6cc..0255a50114 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -291,7 +291,8 @@ export class OrderService {
withExcludedAccounts?: boolean;
}): Promise<Activities> {
let orderBy: Prisma.Enumerable<Prisma.OrderOrderByWithRelationInput> = [
- { date: 'asc' }
+ { date: 'asc' },
+ { id: 'asc' }
];
const where: Prisma.OrderWhereInput = { userId };
@@ -367,7 +368,7 @@ export class OrderService {
}
if (sortColumn) {
- orderBy = [{ [sortColumn]: sortDirection }];
+ orderBy = [{ [sortColumn]: sortDirection }, { id: sortDirection }];
}
if (types) {