perf(server): Reduce database query

This commit is contained in:
syuilo 2021-03-21 22:09:32 +09:00
parent c6fc5b2175
commit 1df6a3c8cc

View file

@ -594,10 +594,13 @@ function saveReply(reply: Note, note: Note) {
}
function incNotesCountOfUser(user: User) {
Users.increment({ id: user.id }, 'notesCount', 1);
Users.update({ id: user.id }, {
updatedAt: new Date()
});
Users.createQueryBuilder().update()
.set({
updatedAt: new Date(),
notesCount: () => '"notesCount" + 1'
})
.where('id = :id', { id: user.id })
.execute();
}
async function extractMentionedUsers(user: User, tokens: ReturnType<typeof parse>): Promise<User[]> {