wip
This commit is contained in:
parent
4f23e6424b
commit
99ca3f0fde
@ -37,6 +37,7 @@ module.exports = {
|
|||||||
'no-useless-escape': ['off'],
|
'no-useless-escape': ['off'],
|
||||||
'no-multi-spaces': ['warn'],
|
'no-multi-spaces': ['warn'],
|
||||||
'no-control-regex': ['warn'],
|
'no-control-regex': ['warn'],
|
||||||
|
'@typescript-eslint/no-var-requires': ['warn'],
|
||||||
'@typescript-eslint/no-inferrable-types': ['warn'],
|
'@typescript-eslint/no-inferrable-types': ['warn'],
|
||||||
'@typescript-eslint/no-empty-function': ['off'],
|
'@typescript-eslint/no-empty-function': ['off'],
|
||||||
'@typescript-eslint/no-non-null-assertion': ['off'],
|
'@typescript-eslint/no-non-null-assertion': ['off'],
|
||||||
|
@ -47,6 +47,7 @@ const removeDuplicates = (array: any[]) => Array.from(new Set(array));
|
|||||||
/**
|
/**
|
||||||
* 様々なチャートの管理を司るクラス
|
* 様々なチャートの管理を司るクラス
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line import/no-default-export
|
||||||
export default abstract class Chart<T extends Record<string, any>> {
|
export default abstract class Chart<T extends Record<string, any>> {
|
||||||
private static readonly columnPrefix = '___';
|
private static readonly columnPrefix = '___';
|
||||||
private static readonly columnDot = '_';
|
private static readonly columnDot = '_';
|
||||||
@ -70,7 +71,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private static convertSchemaToFlatColumnDefinitions(schema: Schema) {
|
private static convertSchemaToFlatColumnDefinitions(schema: Schema) {
|
||||||
const columns = {} as any;
|
const columns = {} as Record<string, unknown>;
|
||||||
const flatColumns = (x: Obj, path?: string) => {
|
const flatColumns = (x: Obj, path?: string) => {
|
||||||
for (const [k, v] of Object.entries(x)) {
|
for (const [k, v] of Object.entries(x)) {
|
||||||
const p = path ? `${path}${this.columnDot}${k}` : k;
|
const p = path ? `${path}${this.columnDot}${k}` : k;
|
||||||
@ -93,8 +94,8 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private static convertFlattenColumnsToObject(x: Record<string, any>): Record<string, any> {
|
private static convertFlattenColumnsToObject(x: Record<string, unknown>): Record<string, unknown> {
|
||||||
const obj = {} as any;
|
const obj = {} as Record<string, unknown>;
|
||||||
for (const k of Object.keys(x).filter(k => k.startsWith(Chart.columnPrefix))) {
|
for (const k of Object.keys(x).filter(k => k.startsWith(Chart.columnPrefix))) {
|
||||||
// now k is ___x_y_z
|
// now k is ___x_y_z
|
||||||
const path = k.substr(Chart.columnPrefix.length).split(Chart.columnDot).join('.');
|
const path = k.substr(Chart.columnPrefix.length).split(Chart.columnDot).join('.');
|
||||||
@ -104,7 +105,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private static convertObjectToFlattenColumns(x: Record<string, any>) {
|
private static convertObjectToFlattenColumns(x: Record<string, unknown>) {
|
||||||
const columns = {} as Record<string, number | unknown[]>;
|
const columns = {} as Record<string, number | unknown[]>;
|
||||||
const flatten = (x: Obj, path?: string) => {
|
const flatten = (x: Obj, path?: string) => {
|
||||||
for (const [k, v] of Object.entries(x)) {
|
for (const [k, v] of Object.entries(x)) {
|
||||||
@ -121,9 +122,9 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private static countUniqueFields(x: Record<string, any>) {
|
private static countUniqueFields(x: Record<string, unknown>) {
|
||||||
const exec = (x: Obj) => {
|
const exec = (x: Obj) => {
|
||||||
const res = {} as Record<string, any>;
|
const res = {} as Record<string, unknown>;
|
||||||
for (const [k, v] of Object.entries(x)) {
|
for (const [k, v] of Object.entries(x)) {
|
||||||
if (typeof v === 'object' && !Array.isArray(v)) {
|
if (typeof v === 'object' && !Array.isArray(v)) {
|
||||||
res[k] = exec(v);
|
res[k] = exec(v);
|
||||||
@ -140,7 +141,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
private static convertQuery(diff: Record<string, number | unknown[]>) {
|
private static convertQuery(diff: Record<string, number | unknown[]>) {
|
||||||
const query: Record<string, Function> = {};
|
const query: Record<string, () => string> = {};
|
||||||
|
|
||||||
for (const [k, v] of Object.entries(diff)) {
|
for (const [k, v] of Object.entries(diff)) {
|
||||||
if (typeof v === 'number') {
|
if (typeof v === 'number') {
|
||||||
@ -337,7 +338,7 @@ export default abstract class Chart<T extends Record<string, any>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public async save() {
|
public async save(): Promise<void> {
|
||||||
if (this.buffer.length === 0) {
|
if (this.buffer.length === 0) {
|
||||||
logger.info(`${this.name}: Write skipped`);
|
logger.info(`${this.name}: Write skipped`);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user