import Chart from "../core.js";
import { name, schema } from "./entities/active-users.js";
const week = 1000 * 60 * 60 * 24 * 7;
const month = 1000 * 60 * 60 * 24 * 30;
const year = 1000 * 60 * 60 * 24 * 365;
/**
 * アクティブユーザーに関するチャート
 */ export default class ActiveUsersChart extends Chart {
    constructor(){
        super(name, schema);
    }
    async tickMajor() {
        return {};
    }
    async tickMinor() {
        return {};
    }
    read(user) {
        this.commit({
            read: [
                user.id
            ],
            registeredWithinWeek: Date.now() - user.createdAt.getTime() < week ? [
                user.id
            ] : [],
            registeredWithinMonth: Date.now() - user.createdAt.getTime() < month ? [
                user.id
            ] : [],
            registeredWithinYear: Date.now() - user.createdAt.getTime() < year ? [
                user.id
            ] : [],
            registeredOutsideWeek: Date.now() - user.createdAt.getTime() > week ? [
                user.id
            ] : [],
            registeredOutsideMonth: Date.now() - user.createdAt.getTime() > month ? [
                user.id
            ] : [],
            registeredOutsideYear: Date.now() - user.createdAt.getTime() > year ? [
                user.id
            ] : []
        });
    }
    async write(user) {
        await this.commit({
            write: [
                user.id
            ]
        });
    }
}
