0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-07 14:12:43 +00:00

fix page size to count

This commit is contained in:
Víctor Losada Hernández
2024-05-22 08:51:49 +02:00
parent 0f9ba1a5ae
commit 879a1f5a57
2 changed files with 21 additions and 18 deletions

View File

@@ -60,9 +60,9 @@ const archive = {
const title = req.query.title || '';
const page = Math.max(parseInt(req.query.page) || 1, 1);
const minPageSize = 6;
const pageSize = Math.max(parseInt(req.query.size) || 10, minPageSize);
const skip = (page - 1) * pageSize;
const mincount = 10;
const count = Math.max(parseInt(req.query.count) || 10, mincount);
const skip = (page - 1) * count;
const brewsQuery = buildBrewsQuery(req.query.legacy, req.query.v3);
const titleConditionsArray = buildTitleConditions(title);
@@ -79,7 +79,7 @@ const archive = {
};
const brews = await HomebrewModel.find(titleQuery, projection)
.skip(skip)
.limit(pageSize)
.limit(count)
.maxTimeMS(5000)
.exec();