fixing logbook skip take order by (#125)
This commit was merged in pull request #125.
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user