fix update query
This commit is contained in:
parent
3b50978f48
commit
3e4961445f
4 changed files with 31 additions and 8 deletions
|
@ -54,15 +54,15 @@ export const scyllaQueries = {
|
||||||
renoteCount: `UPDATE note SET
|
renoteCount: `UPDATE note SET
|
||||||
"renoteCount" = ?,
|
"renoteCount" = ?,
|
||||||
"score" = ?
|
"score" = ?
|
||||||
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? IF EXISTS`,
|
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? AND "userHost" = ? AND "visibility" = ? IF EXISTS`,
|
||||||
repliesCount: `UPDATE note SET
|
repliesCount: `UPDATE note SET
|
||||||
"repliesCount" = ?
|
"repliesCount" = ?
|
||||||
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? IF EXISTS`,
|
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? AND "userHost" = ? AND "visibility" = ? IF EXISTS`,
|
||||||
reactions: `UPDATE note SET
|
reactions: `UPDATE note SET
|
||||||
"emojis" = ?,
|
"emojis" = ?,
|
||||||
"reactions" = ?,
|
"reactions" = ?,
|
||||||
"score" = ?
|
"score" = ?
|
||||||
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? IF EXISTS`,
|
WHERE "createdAtDate" = ? AND "createdAt" = ? AND "userId" = ? AND "userHost" = ? AND "visibility" = ? IF EXISTS`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
homeTimeline: {
|
homeTimeline: {
|
||||||
|
|
|
@ -685,7 +685,15 @@ async function incRenoteCount(renote: Note) {
|
||||||
const score = isNaN(renote.score) ? 0 : renote.score;
|
const score = isNaN(renote.score) ? 0 : renote.score;
|
||||||
await scyllaClient.execute(
|
await scyllaClient.execute(
|
||||||
prepared.note.update.renoteCount,
|
prepared.note.update.renoteCount,
|
||||||
[count + 1, score + 1, renote.createdAt, renote.createdAt, renote.userId],
|
[
|
||||||
|
count + 1,
|
||||||
|
score + 1,
|
||||||
|
renote.createdAt,
|
||||||
|
renote.createdAt,
|
||||||
|
renote.userId,
|
||||||
|
renote.userHost ?? "local",
|
||||||
|
renote.visibility,
|
||||||
|
],
|
||||||
{ prepare: true },
|
{ prepare: true },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -852,9 +860,13 @@ async function insertNote(
|
||||||
// Do not issue BATCH because different queries of inserting post to home timelines involve different partitions
|
// Do not issue BATCH because different queries of inserting post to home timelines involve different partitions
|
||||||
for (const follower of localFollowers) {
|
for (const follower of localFollowers) {
|
||||||
// no need to wait
|
// no need to wait
|
||||||
scyllaClient.execute(prepared.homeTimeline.insert, [follower, ...params], {
|
scyllaClient.execute(
|
||||||
prepare: true,
|
prepared.homeTimeline.insert,
|
||||||
});
|
[follower, ...params],
|
||||||
|
{
|
||||||
|
prepare: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (insert.hasPoll) {
|
if (insert.hasPoll) {
|
||||||
|
@ -1025,7 +1037,14 @@ async function saveReply(reply: Note) {
|
||||||
const count = isNaN(reply.repliesCount) ? 0 : reply.repliesCount;
|
const count = isNaN(reply.repliesCount) ? 0 : reply.repliesCount;
|
||||||
await scyllaClient.execute(
|
await scyllaClient.execute(
|
||||||
prepared.note.update.repliesCount,
|
prepared.note.update.repliesCount,
|
||||||
[count + 1, reply.createdAt, reply.createdAt, reply.userId],
|
[
|
||||||
|
count + 1,
|
||||||
|
reply.createdAt,
|
||||||
|
reply.createdAt,
|
||||||
|
reply.userId,
|
||||||
|
reply.userHost ?? "local",
|
||||||
|
reply.visibility,
|
||||||
|
],
|
||||||
{ prepare: true },
|
{ prepare: true },
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -117,6 +117,8 @@ export default async (
|
||||||
date,
|
date,
|
||||||
date,
|
date,
|
||||||
note.userId,
|
note.userId,
|
||||||
|
note.userHost ?? "local",
|
||||||
|
note.visibility,
|
||||||
],
|
],
|
||||||
{ prepare: true },
|
{ prepare: true },
|
||||||
);
|
);
|
||||||
|
|
|
@ -68,6 +68,8 @@ export default async (
|
||||||
date,
|
date,
|
||||||
date,
|
date,
|
||||||
note.userId,
|
note.userId,
|
||||||
|
note.userHost ?? "local",
|
||||||
|
note.visibility,
|
||||||
],
|
],
|
||||||
{ prepare: true },
|
{ prepare: true },
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue