fix: add NaN check
This commit is contained in:
parent
924a8f9904
commit
38098d52f6
2 changed files with 6 additions and 9 deletions
|
@ -121,7 +121,7 @@ export const prepared = {
|
|||
"score" = ?
|
||||
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "id" = ? IF EXISTS`,
|
||||
repliesCount: `UPDATE note SET
|
||||
"repliesCount" = ?,
|
||||
"repliesCount" = ?
|
||||
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "id" = ? IF EXISTS`,
|
||||
reactions: `UPDATE note SET
|
||||
"emojis" = ?,
|
||||
|
|
|
@ -681,15 +681,11 @@ async function renderNoteOrRenoteActivity(data: Option, note: Note) {
|
|||
|
||||
async function incRenoteCount(renote: Note) {
|
||||
if (scyllaClient) {
|
||||
const count = isNaN(renote.renoteCount) ? 0 : renote.renoteCount;
|
||||
const score = isNaN(renote.score) ? 0 : renote.score;
|
||||
await scyllaClient.execute(
|
||||
prepared.note.update.renoteCount,
|
||||
[
|
||||
renote.renoteCount + 1,
|
||||
renote.score + 1,
|
||||
renote.createdAt,
|
||||
renote.createdAt,
|
||||
renote.id,
|
||||
],
|
||||
[count + 1, score + 1, renote.createdAt, renote.createdAt, renote.id],
|
||||
{ prepare: true },
|
||||
);
|
||||
} else {
|
||||
|
@ -1003,9 +999,10 @@ async function createMentionedEvents(
|
|||
|
||||
async function saveReply(reply: Note) {
|
||||
if (scyllaClient) {
|
||||
const count = isNaN(reply.repliesCount) ? 0 : reply.repliesCount;
|
||||
await scyllaClient.execute(
|
||||
prepared.note.update.repliesCount,
|
||||
[reply.repliesCount + 1, reply.createdAt, reply.createdAt, reply.id],
|
||||
[count + 1, reply.createdAt, reply.createdAt, reply.id],
|
||||
{ prepare: true },
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue