mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-28 16:36:43 -06:00
perf(server): Reduce database query
This commit is contained in:
parent
fb194b855b
commit
82de8b7c50
1 changed files with 8 additions and 3 deletions
|
@ -444,8 +444,13 @@ async function renderNoteOrRenoteActivity(data: Option, note: Note) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function incRenoteCount(renote: Note) {
|
function incRenoteCount(renote: Note) {
|
||||||
Notes.increment({ id: renote.id }, 'renoteCount', 1);
|
Notes.createQueryBuilder().update()
|
||||||
Notes.increment({ id: renote.id }, 'score', 1);
|
.set({
|
||||||
|
renoteCount: () => '"renoteCount" + 1',
|
||||||
|
score: () => '"score" + 1'
|
||||||
|
})
|
||||||
|
.where('id = :id', { id: renote.id })
|
||||||
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function insertNote(user: User, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) {
|
async function insertNote(user: User, data: Option, tags: string[], emojis: string[], mentionedUsers: User[]) {
|
||||||
|
@ -525,7 +530,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
|
||||||
await Notes.insert(insert);
|
await Notes.insert(insert);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await Notes.findOneOrFail(insert.id);
|
return insert;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// duplicate key error
|
// duplicate key error
|
||||||
if (isDuplicateKeyValueError(e)) {
|
if (isDuplicateKeyValueError(e)) {
|
||||||
|
|
Loading…
Reference in a new issue