perf(server): Reduce database query

This commit is contained in:
syuilo 2021-03-21 22:09:32 +09:00
parent a4a9b8707d
commit fb194b855b

View File

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