wip
This commit is contained in:
		
							parent
							
								
									4f23e6424b
								
							
						
					
					
						commit
						99ca3f0fde
					
				
					 2 changed files with 10 additions and 8 deletions
				
			
		|  | @ -37,6 +37,7 @@ module.exports = { | |||
| 		'no-useless-escape': ['off'], | ||||
| 		'no-multi-spaces': ['warn'], | ||||
| 		'no-control-regex': ['warn'], | ||||
| 		'@typescript-eslint/no-var-requires': ['warn'], | ||||
| 		'@typescript-eslint/no-inferrable-types': ['warn'], | ||||
| 		'@typescript-eslint/no-empty-function': ['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>> { | ||||
| 	private static readonly columnPrefix = '___'; | ||||
| 	private static readonly columnDot = '_'; | ||||
|  | @ -70,7 +71,7 @@ export default abstract class Chart<T extends Record<string, any>> { | |||
| 
 | ||||
| 	@autobind | ||||
| 	private static convertSchemaToFlatColumnDefinitions(schema: Schema) { | ||||
| 		const columns = {} as any; | ||||
| 		const columns = {} as Record<string, unknown>; | ||||
| 		const flatColumns = (x: Obj, path?: string) => { | ||||
| 			for (const [k, v] of Object.entries(x)) { | ||||
| 				const p = path ? `${path}${this.columnDot}${k}` : k; | ||||
|  | @ -93,8 +94,8 @@ export default abstract class Chart<T extends Record<string, any>> { | |||
| 	} | ||||
| 
 | ||||
| 	@autobind | ||||
| 	private static convertFlattenColumnsToObject(x: Record<string, any>): Record<string, any> { | ||||
| 		const obj = {} as any; | ||||
| 	private static convertFlattenColumnsToObject(x: Record<string, unknown>): Record<string, unknown> { | ||||
| 		const obj = {} as Record<string, unknown>; | ||||
| 		for (const k of Object.keys(x).filter(k => k.startsWith(Chart.columnPrefix))) { | ||||
| 			// now k is ___x_y_z
 | ||||
| 			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 | ||||
| 	private static convertObjectToFlattenColumns(x: Record<string, any>) { | ||||
| 	private static convertObjectToFlattenColumns(x: Record<string, unknown>) { | ||||
| 		const columns = {} as Record<string, number | unknown[]>; | ||||
| 		const flatten = (x: Obj, path?: string) => { | ||||
| 			for (const [k, v] of Object.entries(x)) { | ||||
|  | @ -121,9 +122,9 @@ export default abstract class Chart<T extends Record<string, any>> { | |||
| 	} | ||||
| 
 | ||||
| 	@autobind | ||||
| 	private static countUniqueFields(x: Record<string, any>) { | ||||
| 	private static countUniqueFields(x: Record<string, unknown>) { | ||||
| 		const exec = (x: Obj) => { | ||||
| 			const res = {} as Record<string, any>; | ||||
| 			const res = {} as Record<string, unknown>; | ||||
| 			for (const [k, v] of Object.entries(x)) { | ||||
| 				if (typeof v === 'object' && !Array.isArray(v)) { | ||||
| 					res[k] = exec(v); | ||||
|  | @ -140,7 +141,7 @@ export default abstract class Chart<T extends Record<string, any>> { | |||
| 
 | ||||
| 	@autobind | ||||
| 	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)) { | ||||
| 			if (typeof v === 'number') { | ||||
|  | @ -337,7 +338,7 @@ export default abstract class Chart<T extends Record<string, any>> { | |||
| 	} | ||||
| 
 | ||||
| 	@autobind | ||||
| 	public async save() { | ||||
| 	public async save(): Promise<void> { | ||||
| 		if (this.buffer.length === 0) { | ||||
| 			logger.info(`${this.name}: Write skipped`); | ||||
| 			return; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue