diff --git a/src/adapter/postgres.spec.ts b/src/adapter/postgres.spec.ts index e9b1cafe35ff475761fc4b45f04edbeaf13016de..2279807dbebaf119f1645df35d6614d52aa6a381 100644 --- a/src/adapter/postgres.spec.ts +++ b/src/adapter/postgres.spec.ts @@ -35,7 +35,7 @@ describe("postgres adapter", () => { let config: any; let adapter: Adapter; let fixture; - before(function (done) { + before(function (done): void { // Arrow function not used to get acces to this and skip the test config = ConfigParser.parse("config/test.yaml"); if (config.adapter === "postgres") { diff --git a/src/adapter/sql.ts b/src/adapter/sql.ts index 3600c1b81b0184357d88f5f723fd92fd61149aed..0ef7ca229ae05aafe5bccd7a111d2430ac71ad27 100644 --- a/src/adapter/sql.ts +++ b/src/adapter/sql.ts @@ -551,7 +551,7 @@ export abstract class SQLAdapter extends Adapter { return r; } - private buildQuery(target: View, views: ExpandedView[], toSort: boolean) { + private buildQuery(target: View, views: ExpandedView[], toSort: boolean): string { const metrics = target.metrics; const dimensions = target.dimensions; const clauses = target.clauses; diff --git a/src/core/aggregate.spec.ts b/src/core/aggregate.spec.ts deleted file mode 100644 index bcc3a3f66649c1e1ee0abaec24d0584e340f9d8c..0000000000000000000000000000000000000000 --- a/src/core/aggregate.spec.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - * - * This file is part of blendb. - * - * blendb is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * blendb is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with blendb. If not, see <http://www.gnu.org/licenses/>. - */ - -import { expect } from "chai"; - -import { Aggregate } from "./aggregate"; - -describe("aggregate class", () => { - it("should be instantiated with an array metrics and one of dimensions", () => { - let aggr = new Aggregate(["met:one"], ["dim:one", "dim:two"]); - expect(aggr).to.be.an("object"); - }); - - it("should not be instantiated with an empty array of metrics", () => { - let aggr = new Aggregate([], ["dim:one", "dim:two"]); - expect(aggr).to.be.an("object"); - }); - - it("should not be instantiated with an empty array of dimensions", () => { - let aggr = new Aggregate(["met:one"], []); - expect(aggr).to.be.an("object"); - }); -}); diff --git a/src/core/aggregate.ts b/src/core/aggregate.ts deleted file mode 100644 index a1e3ccf54da6dde4b858b744bb34124995d9c685..0000000000000000000000000000000000000000 --- a/src/core/aggregate.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre - * Departamento de Informatica - Universidade Federal do Parana - * - * This file is part of blendb. - * - * blendb is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * blendb is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with blendb. If not, see <http://www.gnu.org/licenses/>. - */ - -export interface IAggregateData { - metrics: any; - dimensions: any; -} - -export class Aggregate { - public metrics: string[]; - public dimensions: string[]; - private data: IAggregateData[]; - - constructor(metrics: string[], dimensions: string[], options?: any) { - this.metrics = metrics; - this.dimensions = dimensions; - - this.data = []; - } - - public push(data: IAggregateData) { - this.data.push(data); - } - - public truncate() { - this.data = []; - } - - public find(query: any) { - let result: any = []; - - this.data.forEach((doc: IAggregateData) => { - let match = true; - - for (let key in query) { - if (query.hasOwnProperty(key)) { - let value = query[key]; - - if (doc.dimensions[key] !== value) { - match = false; - break; - } - } - } - - if (match) { - result.push(doc); - } - }); - - return result; - } -} diff --git a/src/core/engine.ts b/src/core/engine.ts index cbbb472950d54d13fc288b571fab0b781ab10336..e2d4ef146e992b6c3c1b26f239579020953d31b2 100644 --- a/src/core/engine.ts +++ b/src/core/engine.ts @@ -18,8 +18,8 @@ * along with blend. If not, see <http://www.gnu.org/licenses/>. */ -import { Dimension } from "./dimension"; -import { Metric } from "./metric"; +import { Dimension, DimensionStrOptions } from "./dimension"; +import { Metric, MetricStrOptions } from "./metric"; import { Clause } from "./clause"; import { Filter } from "./filter"; import { View } from "./view"; @@ -45,11 +45,11 @@ export class Engine { this.graph = new Graph(); } - public getViews() { + public getViews(): View[] { return this.views; } - public getMetricsDescription() { + public getMetricsDescription(): MetricStrOptions[] { return this.metrics.map((i) => i.strOptions()); } @@ -61,11 +61,11 @@ export class Engine { return this.sources.map((i) => i.strOptions()); } - public getDimensionsDescription() { + public getDimensionsDescription(): DimensionStrOptions[] { return this.dimensions.map((i) => i.strOptions()); } - public addView(view: View) { + public addView(view: View): View { if (this.graph.addView(view)) { this.views.push(view); return view; @@ -74,7 +74,7 @@ export class Engine { return null; } - public addEnumType(enumType: EnumType) { + public addEnumType(enumType: EnumType): EnumType { this.enumTypes.push(enumType); return enumType; } @@ -84,7 +84,7 @@ export class Engine { return sourc; } - public addMetric(metric: Metric) { + public addMetric(metric: Metric): Metric { if (this.graph.addMetric(metric)) { this.metrics.push(metric); return metric; @@ -93,7 +93,7 @@ export class Engine { return null; } - public getMetricByName(name: string) { + public getMetricByName(name: string): Metric { let result = this.metrics.find(metric => metric.name === name); if (!result) { @@ -103,7 +103,7 @@ export class Engine { return result; } - public addDimension(dimension: Dimension) { + public addDimension(dimension: Dimension): Dimension { if (this.graph.addDimension(dimension)) { this.dimensions.push(dimension); return dimension; @@ -112,7 +112,7 @@ export class Engine { return null; } - public getDimensionByName(name: string) { + public getDimensionByName(name: string): Dimension { let result = this.dimensions.find(dimension => dimension.name === name); if (!result) { @@ -172,11 +172,11 @@ export class Engine { throw new Error("Filter could not be created: Operator on \"" + strFilter + "\" could not be extracted"); } } - public query (q: Query) { + public query (q: Query): View { return this.selectOptimalView(q); } - private selectOptimalView (q: Query) { + private selectOptimalView (q: Query): View { let optimalViews = this.graph.cover(q); if (optimalViews.length === 0) { throw new Error ("Engine views cannot cover the query"); diff --git a/src/util/graph.ts b/src/util/graph.ts index 2a9e536d4a22ccda8734dede64167b39e0f9c4d7..145b2228f8950f3b5975c5e6c1781a67bb170fba 100644 --- a/src/util/graph.ts +++ b/src/util/graph.ts @@ -282,7 +282,7 @@ export class Graph { the array, adds the id and checkEdge would return true, if the id already exists return false */ - private edge(idV: string, idU: string, value: View) { + private edge(idV: string, idU: string, value: View): void { // Assuming that checkEdge is called first let v: Vertex = this.verticeMap[idV]; let u: Vertex = this.verticeMap[idU]; @@ -522,7 +522,7 @@ export class Graph { /* Check if a set of filter/clauses of a view suits for the query */ - private passConstraints(queryClauses: Clause[], viewClauses: Clause[]) { + private passConstraints(queryClauses: Clause[], viewClauses: Clause[]): boolean { /* TODO: Enhance constraint check. diff --git a/test/monet/fixture.ts b/test/monet/fixture.ts index 3c16edc929e494b53eff2ed4a22e1bf42e58d021..2ff7309193c6c8352590e15e7793a634052c0e6c 100644 --- a/test/monet/fixture.ts +++ b/test/monet/fixture.ts @@ -45,7 +45,7 @@ export class Fixture { this.database = config.database; } - public load(schemas: LoadView[], create: boolean, cb: (err: Error) => void) { + public load(schemas: LoadView[], create: boolean, cb: (err: Error) => void): void { let client = new MDB({ user: this.config.user, dbname: this.config.database, @@ -93,7 +93,7 @@ export class Fixture { }); } - private typeConvertion(t: string) { + private typeConvertion(t: string): string { switch (t) { case "integer": return "INTEGER"; @@ -108,7 +108,7 @@ export class Fixture { } } - private createTransSet(view: View, filePath: string, create: boolean) { + private createTransSet(view: View, filePath: string, create: boolean): TransSet { let props = []; for (let i = 0; i < view.metrics.length; ++i) { diff --git a/test/postgres/fixture.ts b/test/postgres/fixture.ts index c966c551eda39c56bd1c5d6b8febb9857d878dfa..4fdc013438221fe3305ec3c929f3aeb3f16a9bca 100644 --- a/test/postgres/fixture.ts +++ b/test/postgres/fixture.ts @@ -44,7 +44,7 @@ export class Fixture { this.database = config.database; } - public load(schemas: LoadView[], create: boolean, cb: (err: Error) => void) { + public load(schemas: LoadView[], create: boolean, cb: (err: Error) => void): void { let client = new Client(this.config); /* @@ -96,7 +96,7 @@ export class Fixture { }); } - private typeConvertion(t: string) { + private typeConvertion(t: string): string { switch (t) { case "integer": return "INTEGER"; @@ -111,7 +111,7 @@ export class Fixture { } } - private createTransSet(view: View, filePath: string, create: boolean) { + private createTransSet(view: View, filePath: string, create: boolean): TransSet { let props = []; for (let i = 0; i < view.metrics.length; ++i) {