mirror of
https://activitypub.software/TransFem-org/Sharkey
synced 2024-11-26 16:03:02 +00:00
wip
This commit is contained in:
parent
773fe28fcb
commit
c3cd0451ad
1 changed files with 18 additions and 2 deletions
|
@ -1,6 +1,6 @@
|
|||
import { INote } from '../models/note';
|
||||
import Chart, { IChart } from '../models/chart';
|
||||
import { isLocalUser } from '../models/user';
|
||||
import { isLocalUser, IUser } from '../models/user';
|
||||
|
||||
async function getTodayStats(): Promise<IChart> {
|
||||
const now = new Date();
|
||||
|
@ -22,7 +22,7 @@ async function getTodayStats(): Promise<IChart> {
|
|||
// 「昨日の」と決め打ちせずに「もっとも最近の」とします
|
||||
const mostRecentStats = await Chart.findOne({}, {
|
||||
sort: {
|
||||
createdAt: -1
|
||||
date: -1
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -114,6 +114,22 @@ async function update(inc: any) {
|
|||
});
|
||||
}
|
||||
|
||||
export async function updateUserStats(user: IUser, isAdditional: boolean) {
|
||||
const inc = {} as any;
|
||||
|
||||
const val = isAdditional ? 1 : -1;
|
||||
|
||||
if (isLocalUser(user)) {
|
||||
inc['users.local.total'] = val;
|
||||
inc['users.local.diff'] = val;
|
||||
} else {
|
||||
inc['users.remote.total'] = val;
|
||||
inc['users.remote.diff'] = val;
|
||||
}
|
||||
|
||||
await update(inc);
|
||||
}
|
||||
|
||||
export async function updateNoteStats(note: INote, isAdditional: boolean) {
|
||||
const inc = {} as any;
|
||||
|
||||
|
|
Loading…
Reference in a new issue