Skip to content

Commit 3714232

Browse files
authored
Merge pull request #68 from icefoganalytics/caleb/hot-fix
maybe fix for aircrash pagination
2 parents dc38281 + 3f1c688 commit 3714232

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

api/routes/aircrash-router.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ aircrashRouter.use(authorize(airCrashViewers));
3434

3535
aircrashRouter.get(
3636
'/',
37-
[query('page').default(0).isInt(), query('limit').default(10).isInt({ gt: 0 })],
37+
[query('page').default(0).isInt(), query('perPage').default(10).isInt({ gt: 0 })],
3838
ReturnValidationErrors,
3939
async (req: Request, res: Response) => {
4040
try {
@@ -55,7 +55,7 @@ aircrashRouter.get(
5555
} = req.query;
5656

5757
const page = parseInt(req.query.page?.toString() || '') || 1;
58-
const perPage = parseInt(req.query.limit?.toString() || '') || 10;
58+
const perPage = parseInt(req.query.perPage?.toString() || '') || 10;
5959

6060
const data = await aircrashService.doSearch(page, perPage, {
6161
textToMatch,

api/services/aircrash-service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ export class AircrashService {
4747

4848
// _TODO_ move into base-controller.ts
4949
const MAX_PER_PAGE = 1000;
50-
const limit = Math.max(1, Math.min(perPage, MAX_PER_PAGE));
50+
let limit = 0;
51+
if (perPage === -1) {
52+
limit = MAX_PER_PAGE;
53+
} else {
54+
limit = Math.max(1, Math.min(perPage, MAX_PER_PAGE));
55+
}
5156
const offset = (page - 1) * limit;
5257

5358
const aircrashes = await db

web/src/controllers/aircrash.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { api } from './config';
33
export default {
44
async get(
55
page,
6-
limit,
6+
perPage,
77
textToMatch,
88
sortBy,
99
sort,
@@ -23,7 +23,7 @@ export default {
2323
crossdomain: true,
2424
params: {
2525
page,
26-
limit,
26+
perPage,
2727
textToMatch,
2828
sortBy,
2929
sort,

0 commit comments

Comments
 (0)