Skip to content

Commit 2128908

Browse files
committed
pagination fix
1 parent 864f47c commit 2128908

File tree

4 files changed

+8
-43
lines changed

4 files changed

+8
-43
lines changed

backend/src/entities/user-secret/application/data-structures/get-audit-log.ds.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { SecretActionEnum } from '../../../secret-access-log/secret-access-log.entity.js';
2+
import { PaginationDs } from '../../../table/application/data-structures/pagination.ds.js';
23

34
export class GetAuditLogDS {
45
userId: string;
@@ -23,10 +24,5 @@ export class AuditLogEntryDS {
2324

2425
export class AuditLogListDS {
2526
data: AuditLogEntryDS[];
26-
pagination: {
27-
total: number;
28-
page: number;
29-
limit: number;
30-
totalPages: number;
31-
};
27+
pagination: PaginationDs;
3228
}

backend/src/entities/user-secret/application/dto/audit-log.dto.ts

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ApiProperty } from '@nestjs/swagger';
22
import { SecretActionEnum } from '../../../secret-access-log/secret-access-log.entity.js';
3+
import { PaginationDs } from '../../../table/application/data-structures/pagination.ds.js';
34

45
export class AuditLogUserDto {
56
@ApiProperty({
@@ -78,36 +79,6 @@ export class AuditLogEntryDto {
7879
errorMessage?: string;
7980
}
8081

81-
export class AuditLogPaginationDto {
82-
@ApiProperty({
83-
type: Number,
84-
description: 'Total number of audit log entries',
85-
example: 150,
86-
})
87-
total: number;
88-
89-
@ApiProperty({
90-
type: Number,
91-
description: 'Current page number',
92-
example: 1,
93-
})
94-
page: number;
95-
96-
@ApiProperty({
97-
type: Number,
98-
description: 'Number of entries per page',
99-
example: 50,
100-
})
101-
limit: number;
102-
103-
@ApiProperty({
104-
type: Number,
105-
description: 'Total number of pages',
106-
example: 3,
107-
})
108-
totalPages: number;
109-
}
110-
11182
export class AuditLogResponseDto {
11283
@ApiProperty({
11384
type: AuditLogEntryDto,
@@ -117,8 +88,8 @@ export class AuditLogResponseDto {
11788
data: AuditLogEntryDto[];
11889

11990
@ApiProperty({
120-
type: AuditLogPaginationDto,
91+
type: PaginationDs,
12192
description: 'Pagination information',
12293
})
123-
pagination: AuditLogPaginationDto;
94+
pagination: PaginationDs;
12495
}

backend/src/entities/user-secret/use-cases/get-secret-audit-log.use.case.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ export class GetSecretAuditLogUseCase
4646
data: logs.map((log) => buildAuditLogEntryDS(log)),
4747
pagination: {
4848
total,
49-
page,
50-
limit,
51-
totalPages: Math.ceil(total / limit),
49+
currentPage: page,
50+
perPage: limit,
51+
lastPage: Math.ceil(total / limit),
5252
},
5353
};
5454
}

backend/test/ava-tests/non-saas-tests/non-saas-secrets-e2e.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,6 @@ test.serial(`${currentTest}?page=1&limit=2 - should paginate audit log`, async (
485485
.set('Content-Type', 'application/json')
486486
.set('Accept', 'application/json');
487487

488-
const connectionId = JSON.parse(createdConnection.text).id;
489-
490488
const response = await request(app.getHttpServer())
491489
.get('/secrets/test-api-key/audit-log?page=1&limit=2')
492490
.set('Cookie', token)

0 commit comments

Comments
 (0)