Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node.js bug fix #408

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions webapp/node/src/handlers/stats-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export const getUserStatisticsHandler = [
.catch(throwErrorWith('failed to count reactions'))

const [[{ 'IFNULL(SUM(l2.tip), 0)': tips }]] = await conn
.query<({ 'IFNULL(SUM(l2.tip), 0)': number } & RowDataPacket)[]>(
.query<
({ 'IFNULL(SUM(l2.tip), 0)': string | number } & RowDataPacket)[]
>(
`
SELECT IFNULL(SUM(l2.tip), 0) FROM users u
INNER JOIN livestreams l ON l.user_id = u.id
Expand All @@ -68,7 +70,7 @@ export const getUserStatisticsHandler = [

ranking.push({
username: user.name,
score: reaction + tips,
score: reaction + Number(tips),
})
}

Expand Down Expand Up @@ -219,7 +221,9 @@ export const getLivestreamStatisticsHandler = [
.catch(throwErrorWith('failed to count reactions'))

const [[{ 'IFNULL(SUM(l2.tip), 0)': totalTip }]] = await conn
.query<({ 'IFNULL(SUM(l2.tip), 0)': number } & RowDataPacket)[]>(
.query<
({ 'IFNULL(SUM(l2.tip), 0)': number | string } & RowDataPacket)[]
>(
'SELECT IFNULL(SUM(l2.tip), 0) FROM livestreams l INNER JOIN livecomments l2 ON l.id = l2.livestream_id WHERE l.id = ?',
[livestream.id],
)
Expand All @@ -228,7 +232,7 @@ export const getLivestreamStatisticsHandler = [
ranking.push({
livestreamId: livestream.id,
title: livestream.title,
score: reactionCount + totalTip,
score: reactionCount + Number(totalTip),
})
}
ranking.sort((a, b) => {
Expand Down
3 changes: 2 additions & 1 deletion webapp/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"compilerOptions": {
"types": ["bun-types"]
"module": "NodeNext",
"target": "ESNext"
}
}