Commit 30658b05 authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira

Merge branch 'issue/68' into 'develop'

Issue #68: Add call-signature for method

See merge request !59
parents 0211f805 e24532fb
Pipeline #15415 failed with stages
in 47 seconds
......@@ -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") {
......
......@@ -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;
......
/*
* 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");
});
});
/*
* 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;
}
}
......@@ -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");
......
......@@ -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.
......
......@@ -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) {
......
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment