fixing logbook skip take order by (#125)

This commit was merged in pull request #125.
This commit is contained in:
2026-03-23 20:19:58 -05:00
committed by GitHub
parent 5de5a165da
commit d8513e6dd0
6 changed files with 29 additions and 14 deletions

View File

@@ -234,14 +234,14 @@ describe('LogService', () => {
const count = 1
const morePages = false
jest.spyOn(mockLogRepository, 'findAndCount').mockReturnValue([logs, count, morePages]);
jest.spyOn(mockQueryBuilder, 'getManyAndCount').mockReturnValue([logs, count, morePages]);
const {entities, total, hasNextPage} = await service.findLogsWithCount();
expect(entities).toEqual(logs);
expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages);
expect(mockLogRepository.findAndCount).toHaveBeenCalled();
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
})
it('findLogsWithTracks => should find log entries with tracks', async () => {
@@ -294,7 +294,7 @@ describe('LogService', () => {
expect(entities).toEqual(logs);
expect(count).toEqual(total);
expect(hasNextPage).toEqual(morePages);
expect(mockLogRepository.findAndCount).toHaveBeenCalled();
expect(mockQueryBuilder.getManyAndCount).toHaveBeenCalled();
})
it('update => should update a log entry', async () => {

View File

@@ -25,11 +25,22 @@ export class LogService {
}
async findLogsWithCount(skip?: number, take?: number): Promise<Logs> {
const [entities, total] = await this.logRepository.findAndCount({
take,
skip,
relations: ['pilot', 'tracks']
})
// const [entities, total] = await this.logRepository.findAndCount({
// take,
// skip,
// order: {
// date: 'DESC'
// },
// relations: ['pilot', 'tracks']
// })
const [entities, total] = await this.logRepository
.createQueryBuilder('logs')
.innerJoinAndSelect('logs.pilot', 'pilot')
.orderBy('logs.date', 'DESC')
.skip(skip)
.take(take)
.getManyAndCount()
return {
entities,