From 59266b319099be8f54010b4826ab0c60823ad9af Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 22 Oct 2018 03:41:50 +0900 Subject: [PATCH] Fix bug --- src/services/stats.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/services/stats.ts b/src/services/stats.ts index 1cb9e490f2..935b16d6f5 100644 --- a/src/services/stats.ts +++ b/src/services/stats.ts @@ -61,10 +61,13 @@ abstract class Stats { protected collection: ICollection>; protected abstract async getTemplate(init: boolean, latest?: T, group?: any): Promise; - constructor(name: string) { + constructor(name: string, grouped = false) { this.collection = db.get>(`stats.${name}`); - this.collection.createIndex({ span: -1, date: -1 }, { unique: true }); - this.collection.createIndex('group'); + if (grouped) { + this.collection.createIndex({ span: -1, date: -1, group: -1 }, { unique: true }); + } else { + this.collection.createIndex({ span: -1, date: -1 }, { unique: true }); + } } @autobind @@ -668,7 +671,7 @@ type HashtagLog = { class HashtagStats extends Stats { constructor() { - super('hashtag'); + super('hashtag', true); } @autobind @@ -743,7 +746,7 @@ type FollowingLog = { class FollowingStats extends Stats { constructor() { - super('following'); + super('following', true); } @autobind