Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍
TypeScript angularetffinancefintechghostfoliohacktoberfestinvestingnestjsosspersonal-financeportfolioprismasoftwarestocktrackertradingtypescriptwealth-managementweb
Bugfix/fix pagination issue in market data and user endpoint by adding secondary sort criterion (#5521)
Thomas Kaulf7f942d08d63
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3a557d40fd..962bcf07f7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -18,6 +18,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- Refactored the login with access token dialog component to standalone- Prefixed the `crypto`, `fs` and `path` imports with `node:`+### Fixed++- Fixed a pagination issue in the market data endpoint by adding `id` as a secondary sort criterion to ensure consistent ordering in the admin control panel+- Fixed a pagination issue in the user endpoint by adding `id` as a secondary sort criterion to ensure consistent ordering in the admin control panel+## 2.198.0 - 2025-09-11### Changeddiff --git a/apps/api/src/app/admin/admin.service.ts b/apps/api/src/app/admin/admin.service.tsindex 2918d9d7d5..11f6f05991 100644--- a/apps/api/src/app/admin/admin.service.ts+++ b/apps/api/src/app/admin/admin.service.ts@@ -192,7 +192,7 @@ export class AdminService {filters,presetId,sortColumn,- sortDirection,+ sortDirection = 'asc',skip,take = Number.MAX_SAFE_INTEGER}: {@@ -262,11 +262,13 @@ export class AdminService {orderBy = [{ [sortColumn]: sortDirection }];if (sortColumn === 'activitiesCount') {- orderBy = {- activities: {- _count: sortDirection+ orderBy = [+ {+ activities: {+ _count: sortDirection+ }}- };+ ];}}@@ -275,10 +277,10 @@ export class AdminService {try {const symbolProfileResult = await Promise.all([extendedPrismaClient.symbolProfile.findMany({- orderBy,skip,take,where,+ orderBy: [...orderBy, { id: sortDirection }],select: {_count: {select: {@@ -817,17 +819,21 @@ export class AdminService {skip?: number;take?: number;}): Promise<AdminUsers['users']> {- let orderBy: Prisma.UserOrderByWithRelationInput = {- createdAt: 'desc'- };+ let orderBy: Prisma.Enumerable<Prisma.UserOrderByWithRelationInput> = [+ { createdAt: 'desc' }+ ];+let where: Prisma.UserWhereInput;if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {- orderBy = {- analytics: {- lastRequestAt: 'desc'+ orderBy = [+ {+ analytics: {+ lastRequestAt: 'desc'+ }}- };+ ];+where = {NOT: {analytics: null@@ -836,10 +842,10 @@ export class AdminService {}const usersWithAnalytics = await this.prismaService.user.findMany({- orderBy,skip,take,where,+ orderBy: [...orderBy, { id: 'desc' }],select: {_count: {select: { accounts: true, activities: true }diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.tsindex fd50f5e743..11579bbf1b 100644--- a/apps/api/src/app/order/order.service.ts+++ b/apps/api/src/app/order/order.service.ts@@ -325,7 +325,7 @@ export class OrderService {includeDrafts = false,skip,sortColumn,- sortDirection,+ sortDirection = 'asc',startDate,take = Number.MAX_SAFE_INTEGER,types,@@ -347,9 +347,9 @@ export class OrderService {withExcludedAccountsAndActivities?: boolean;}): Promise<Activities> {let orderBy: Prisma.Enumerable<Prisma.OrderOrderByWithRelationInput> = [- { date: 'asc' },- { id: 'asc' }+ { date: 'asc' }];+const where: Prisma.OrderWhereInput = { userId };if (endDate || startDate) {@@ -483,7 +483,7 @@ export class OrderService {}if (sortColumn) {- orderBy = [{ [sortColumn]: sortDirection }, { id: sortDirection }];+ orderBy = [{ [sortColumn]: sortDirection }];}if (types) {@@ -506,7 +506,6 @@ export class OrderService {const [orders, count] = await Promise.all([this.orders({- orderBy,skip,take,where,@@ -519,7 +518,8 @@ export class OrderService {// eslint-disable-next-line @typescript-eslint/naming-conventionSymbolProfile: true,tags: true- }+ },+ orderBy: [...orderBy, { id: sortDirection }]}),this.prismaService.order.count({ where })]);