@@ -101,7 +101,7 @@ router.get('/:dataType',
|
|||||||
const dataType = req.params.dataType as keyof typeof path
|
const dataType = req.params.dataType as keyof typeof path
|
||||||
|
|
||||||
const selection = data.select([sum<number>('kills').as('kills'), sum<number>('deaths').as('deaths'), sum<number>('deaths_with_weapon').as('deaths_while_equipped'), path[dataType], sum<number>('total_distance').as('total_distance'), max('max_distance').as('max_distance')]).groupBy(path[dataType])
|
const selection = data.select([sum<number>('kills').as('kills'), sum<number>('deaths').as('deaths'), sum<number>('deaths_with_weapon').as('deaths_while_equipped'), path[dataType], sum<number>('total_distance').as('total_distance'), max('max_distance').as('max_distance')]).groupBy(path[dataType])
|
||||||
const test = (await selection.execute()).reduce<Record<string, KillRecord>>((acc, curr) => {
|
const result = (await selection.execute()).reduce<Record<string, KillRecord>>((acc, curr) => {
|
||||||
acc[curr[path[dataType]]] = {
|
acc[curr[path[dataType]]] = {
|
||||||
kills: Number(curr.kills),
|
kills: Number(curr.kills),
|
||||||
deaths: Number(curr.deaths),
|
deaths: Number(curr.deaths),
|
||||||
@@ -111,7 +111,10 @@ router.get('/:dataType',
|
|||||||
}
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
res.send(test)
|
const dataString = JSON.stringify(result)
|
||||||
|
const buffer = Buffer.from(dataString)
|
||||||
|
const size = buffer.length
|
||||||
|
res.status(200).setHeader('X-File-Size', size).setHeader('Content-Type', 'application/json').send(buffer)
|
||||||
})()
|
})()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user