diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-08-18 20:26:01 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-08-18 20:26:01 +0900 |
| commit | 773fe28fcb681e16d5bab6f09b8ee4bb372c0ee9 (patch) | |
| tree | c0e24489daabca5d97b7744e43e26e437c057273 /src/services | |
| parent | wip (diff) | |
| download | sharkey-773fe28fcb681e16d5bab6f09b8ee4bb372c0ee9.tar.gz sharkey-773fe28fcb681e16d5bab6f09b8ee4bb372c0ee9.tar.bz2 sharkey-773fe28fcb681e16d5bab6f09b8ee4bb372c0ee9.zip | |
wip
Diffstat (limited to 'src/services')
| -rw-r--r-- | src/services/update-chart.ts | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/services/update-chart.ts b/src/services/update-chart.ts index c1f212c9d8..f6835fb789 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; } } |