mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-03 16:43:08 +02:00
38 lines
709 B
TypeScript
38 lines
709 B
TypeScript
|
import autobind from 'autobind-decorator';
|
||
|
import * as mongo from 'mongodb';
|
||
|
import Chart, { Partial } from './';
|
||
|
|
||
|
/**
|
||
|
* ハッシュタグに関するチャート
|
||
|
*/
|
||
|
type HashtagLog = {
|
||
|
/**
|
||
|
* 投稿された数
|
||
|
*/
|
||
|
count: number;
|
||
|
};
|
||
|
|
||
|
class HashtagChart extends Chart<HashtagLog> {
|
||
|
constructor() {
|
||
|
super('hashtag', true);
|
||
|
}
|
||
|
|
||
|
@autobind
|
||
|
protected async getTemplate(init: boolean, latest?: HashtagLog): Promise<HashtagLog> {
|
||
|
return {
|
||
|
count: 0
|
||
|
};
|
||
|
}
|
||
|
|
||
|
@autobind
|
||
|
public async update(hashtag: string, userId: mongo.ObjectId) {
|
||
|
const inc: Partial<HashtagLog> = {
|
||
|
count: 1
|
||
|
};
|
||
|
|
||
|
await this.incIfUnique(inc, 'users', userId.toHexString(), hashtag);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new HashtagChart();
|