Compare commits

..

3 Commits

Author SHA1 Message Date
00cbe6eaa7 fixing flights skip take order by 2026-03-22 10:17:24 -05:00
1ad064e41f fixing flights skip take order by 2026-03-22 10:12:04 -05:00
d7c584b391 fixing flights skip take order by 2026-03-22 10:11:12 -05:00
7 changed files with 16 additions and 30 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "api", "name": "api",
"version": "2.1.3", "version": "2.1.1",
"description": "", "description": "",
"author": "", "author": "",
"private": true, "private": true,

View File

@@ -62,7 +62,7 @@ export class LogInterceptor implements NestInterceptor {
const logs = publicData.slice(0, 5) const logs = publicData.slice(0, 5)
return { return {
entities: logs, entities: publicData,
total: data.total, total: data.total,
hasNextPage: false hasNextPage: false
}; };
@@ -71,6 +71,7 @@ export class LogInterceptor implements NestInterceptor {
return publicData return publicData
} }
} }
}) })
); );

View File

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

View File

@@ -25,22 +25,11 @@ export class LogService {
} }
async findLogsWithCount(skip?: number, take?: number): Promise<Logs> { async findLogsWithCount(skip?: number, take?: number): Promise<Logs> {
// const [entities, total] = await this.logRepository.findAndCount({ const [entities, total] = await this.logRepository.findAndCount({
// take, take,
// skip, skip,
// order: { relations: ['pilot', 'tracks']
// 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 { return {
entities, entities,

View File

@@ -1,7 +1,7 @@
{ {
"name": "client", "name": "client",
"private": true, "private": true,
"version": "2.1.3", "version": "2.1.1",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

View File

@@ -380,13 +380,13 @@ const Logbook: React.FC<unknown> = () => {
setPageIndex setPageIndex
} = table; } = table;
const getLogbookEntries = async (pageIndex: number, pageSize: number) => { const getLogbookEntries = async (pageIndex?: number, pageSize?: number) => {
try { try {
dispatch({ type: 'SET_IS_LOADING', payload: true }); dispatch({ type: 'SET_IS_LOADING', payload: true });
const response: AxiosResponse = await httpClient.get(`api/logs`, { const response: AxiosResponse = await httpClient.get(`api/logs`, {
params: { params: {
skip: pageIndex * pageSize, skip: pageIndex,
take: pageSize take: pageSize
} }
}); });
@@ -527,10 +527,6 @@ const Logbook: React.FC<unknown> = () => {
dispatch({ type: 'SET_PAGES', payload: pages }) dispatch({ type: 'SET_PAGES', payload: pages })
}, [state.totalEntries, state.pagination?.pageSize]) }, [state.totalEntries, state.pagination?.pageSize])
useEffect(() => {
console.log(state.pagination)
}, [state.pagination])
return ( return (
<> <>
<div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}> <div className={`${screenSize === ScreenSize.SM ? 'mr-4 ml-4' : 'mr-10 ml-10'} grid grid-cols-12`}>
@@ -573,7 +569,7 @@ const Logbook: React.FC<unknown> = () => {
> >
<option value={10}>10</option> <option value={10}>10</option>
<option value={25}>25</option> <option value={25}>25</option>
<option value={50}>50</option> <option value={3}>50</option>
<option value={state.totalEntries}>All</option> <option value={state.totalEntries}>All</option>
</select> </select>
</label> </label>

View File

@@ -1,6 +1,6 @@
{ {
"name": "@noahspan/flying", "name": "@noahspan/flying",
"version": "2.1.3", "version": "2.1.1",
"scripts": { "scripts": {
"start": "node api/dist/main", "start": "node api/dist/main",
"format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"", "format": "prettier --write \"**/src/**/*.ts\" \"**/test/**/*.ts\"",