43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { KVs } from "../core.js";
|
|
import Chart from "../core.js";
|
|
import { DriveFiles } from "@/models/index.js";
|
|
import { Not, IsNull } from "typeorm";
|
|
import type { DriveFile } from "@/models/entities/drive-file.js";
|
|
import { name, schema } from "./entities/drive.js";
|
|
|
|
/**
|
|
* ドライブに関するチャート
|
|
*/
|
|
|
|
export default class DriveChart extends Chart<typeof schema> {
|
|
constructor() {
|
|
super(name, schema);
|
|
}
|
|
|
|
protected async tickMajor(): Promise<Partial<KVs<typeof schema>>> {
|
|
return {};
|
|
}
|
|
|
|
protected async tickMinor(): Promise<Partial<KVs<typeof schema>>> {
|
|
return {};
|
|
}
|
|
|
|
public async update(file: DriveFile, isAdditional: boolean): Promise<void> {
|
|
const fileSizeKb = file.size / 1000;
|
|
await this.commit(
|
|
file.userHost === null
|
|
? {
|
|
"local.incCount": isAdditional ? 1 : 0,
|
|
"local.incSize": isAdditional ? fileSizeKb : 0,
|
|
"local.decCount": isAdditional ? 0 : 1,
|
|
"local.decSize": isAdditional ? 0 : fileSizeKb,
|
|
}
|
|
: {
|
|
"remote.incCount": isAdditional ? 1 : 0,
|
|
"remote.incSize": isAdditional ? fileSizeKb : 0,
|
|
"remote.decCount": isAdditional ? 0 : 1,
|
|
"remote.decSize": isAdditional ? 0 : fileSizeKb,
|
|
},
|
|
);
|
|
}
|
|
}
|