Update the character list to use the server side table stuff

This commit is contained in:
iamBadgers
2024-06-09 19:11:41 -07:00
parent aa4f17df06
commit 1544117aae
5 changed files with 65 additions and 47 deletions

View File

@@ -33,14 +33,15 @@ export function addCharacterApis(app, jsonParser) {
order: orderBy,
where: filter
})
const pageCount = Math.ceil(
(await Character.count({
const totalCount = await Character.count({
where: filter
})) / count
})
const pageCount = Math.ceil(
totalCount / count
)
res.setHeader('Content-Type', 'application/json')
res.send({ characterData, pageCount })
res.send({ characterData, pageCount, totalCount })
} catch (e) {
if (e instanceof ParsingError) {
res.status(400).send('Could not parse filter.')