Browse Source

Add id as secondary sort criterion to ensure consistent ordering

pull/5521/head
Thomas Kaul 2 months ago
parent
commit
923dd53f62
  1. 25
      apps/api/src/app/admin/admin.service.ts

25
apps/api/src/app/admin/admin.service.ts

@ -204,7 +204,7 @@ export class AdminService {
take?: number; take?: number;
}): Promise<AdminMarketData> { }): Promise<AdminMarketData> {
let orderBy: Prisma.Enumerable<Prisma.SymbolProfileOrderByWithRelationInput> = let orderBy: Prisma.Enumerable<Prisma.SymbolProfileOrderByWithRelationInput> =
[{ symbol: 'asc' }]; [{ symbol: 'asc' }, { id: 'asc' }];
const where: Prisma.SymbolProfileWhereInput = {}; const where: Prisma.SymbolProfileWhereInput = {};
if (presetId === 'BENCHMARKS') { if (presetId === 'BENCHMARKS') {
@ -259,14 +259,17 @@ export class AdminService {
} }
if (sortColumn) { if (sortColumn) {
orderBy = [{ [sortColumn]: sortDirection }]; orderBy = [{ [sortColumn]: sortDirection }, { id: sortDirection }];
if (sortColumn === 'activitiesCount') { if (sortColumn === 'activitiesCount') {
orderBy = { orderBy = [
{
activities: { activities: {
_count: sortDirection _count: sortDirection
} }
}; },
{ id: sortDirection }
];
} }
} }
@ -817,17 +820,21 @@ export class AdminService {
skip?: number; skip?: number;
take?: number; take?: number;
}): Promise<AdminUsers['users']> { }): Promise<AdminUsers['users']> {
let orderBy: Prisma.UserOrderByWithRelationInput = { let orderBy: Prisma.Enumerable<Prisma.UserOrderByWithRelationInput> = [
createdAt: 'desc' { createdAt: 'desc' },
}; { id: 'desc' }
];
let where: Prisma.UserWhereInput; let where: Prisma.UserWhereInput;
if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) { if (this.configurationService.get('ENABLE_FEATURE_SUBSCRIPTION')) {
orderBy = { orderBy = [
{
analytics: { analytics: {
lastRequestAt: 'desc' lastRequestAt: 'desc'
} }
}; },
{ id: 'desc' }
];
where = { where = {
NOT: { NOT: {
analytics: null analytics: null

Loading…
Cancel
Save