From 773fe28fcb681e16d5bab6f09b8ee4bb372c0ee9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 18 Aug 2018 20:26:01 +0900 Subject: [PATCH] wip --- src/services/update-chart.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/services/update-chart.ts b/src/services/update-chart.ts index c1f212c9d..f6835fb78 100644 --- a/src/services/update-chart.ts +++ b/src/services/update-chart.ts @@ -114,28 +114,30 @@ async function update(inc: any) { }); } -export async function incNote(note: INote) { +export async function updateNoteStats(note: INote, isAdditional: boolean) { const inc = {} as any; + const val = isAdditional ? 1 : -1; + if (isLocalUser(note._user)) { - inc['notes.local.total'] = 1; + inc['notes.local.total'] = val; if (note.replyId != null) { - inc['notes.local.diffs.reply'] = 1; + inc['notes.local.diffs.reply'] = val; } else if (note.renoteId != null) { - inc['notes.local.diffs.renote'] = 1; + inc['notes.local.diffs.renote'] = val; } else { - inc['notes.local.diffs.normal'] = 1; + inc['notes.local.diffs.normal'] = val; } } else { - inc['notes.remote.total'] = 1; + inc['notes.remote.total'] = val; if (note.replyId != null) { - inc['notes.remote.diffs.reply'] = 1; + inc['notes.remote.diffs.reply'] = val; } else if (note.renoteId != null) { - inc['notes.remote.diffs.renote'] = 1; + inc['notes.remote.diffs.renote'] = val; } else { - inc['notes.remote.diffs.normal'] = 1; + inc['notes.remote.diffs.normal'] = val; } }