Delete SimpleSchema/SimpleObj

and Move schemas to dedicated files
This commit is contained in:
tamaina
2022-01-14 03:16:39 +09:00
parent 21b6176d97
commit 59a5d00d6b
48 changed files with 1546 additions and 1570 deletions

View File

@@ -7,7 +7,7 @@
import * as nestedProperty from 'nested-property';
import autobind from 'autobind-decorator';
import Logger from '../logger';
import { SimpleSchema } from '@/misc/simple-schema';
import { Schema } from '@/misc/schema';
import { EntitySchema, getRepository, Repository, LessThan, Between } from 'typeorm';
import { dateUTC, isTimeSame, isTimeBefore, subtractTime, addTime } from '@/prelude/time';
import { getChartInsertLock } from '@/misc/app-lock';
@@ -57,7 +57,7 @@ export default abstract class Chart<T extends Record<string, any>> {
diff: DeepPartial<T>;
group: string | null;
}[] = [];
public schema: SimpleSchema;
public schema: Schema;
protected repositoryForHour: Repository<Log>;
protected repositoryForDay: Repository<Log>;
@@ -71,7 +71,7 @@ export default abstract class Chart<T extends Record<string, any>> {
protected abstract fetchActual(group: string | null): Promise<DeepPartial<T>>;
@autobind
private static convertSchemaToFlatColumnDefinitions(schema: SimpleSchema) {
private static convertSchemaToFlatColumnDefinitions(schema: Schema) {
const columns = {} as Record<string, unknown>;
const flatColumns = (x: Obj, path?: string) => {
for (const [k, v] of Object.entries(x)) {
@@ -183,7 +183,7 @@ export default abstract class Chart<T extends Record<string, any>> {
}
@autobind
public static schemaToEntity(name: string, schema: SimpleSchema, grouped = false): {
public static schemaToEntity(name: string, schema: Schema, grouped = false): {
hour: EntitySchema,
day: EntitySchema,
} {
@@ -233,7 +233,7 @@ export default abstract class Chart<T extends Record<string, any>> {
};
}
constructor(name: string, schema: SimpleSchema, grouped = false) {
constructor(name: string, schema: Schema, grouped = false) {
this.name = name;
this.schema = schema;
@@ -573,8 +573,8 @@ export default abstract class Chart<T extends Record<string, any>> {
}
}
export function convertLog(logSchema: SimpleSchema): SimpleSchema {
const v: SimpleSchema = JSON.parse(JSON.stringify(logSchema)); // copy
export function convertLog(logSchema: Schema): Schema {
const v: Schema = JSON.parse(JSON.stringify(logSchema)); // copy
if (v.type === 'number') {
v.type = 'array';
v.items = {