Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit 4b9198b

Browse files
authored
Merge pull request #228 from doitintl/code-climate
More Code Climate
2 parents e08504a + 783c188 commit 4b9198b

File tree

4 files changed

+24
-32
lines changed

4 files changed

+24
-32
lines changed

dist/module.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58893,9 +58893,9 @@ function () {
5889358893
return g.type === "alias";
5889458894
});
5889558895

58896-
if (hll) {
58897-
numOfColumns += 1;
58896+
numOfColumns += 1;
5889858897

58898+
if (hll) {
5889958899
if (hll.type === "hll_count.merge") {
5890058900
hllInd = numOfColumns;
5890158901
}
@@ -58906,8 +58906,6 @@ function () {
5890658906
query += " AS " + alias.params[0];
5890758907
}
5890858908
} else {
58909-
numOfColumns += 1;
58910-
5891158909
if (alias) {
5891258910
query += ",\n" + alias.params[0];
5891358911
} else {
@@ -58963,9 +58961,6 @@ function () {
5896358961

5896458962
if (hll !== undefined) {
5896558963
this.hll = hll;
58966-
}
58967-
58968-
if (hll !== undefined) {
5896958964
return "HLL_COUNT.INIT (CAST(" + columnName.params[0] + " as NUMERIC)) as respondents_hll";
5897058965
}
5897158966

@@ -58990,21 +58985,19 @@ function () {
5899058985

5899158986
overParts.push("ORDER BY " + this.buildTimeColumn(false));
5899258987
var over = overParts.join(" ");
58993-
var curr = void 0;
58988+
var curr = query;
5899458989
var prev = void 0;
5899558990
var tmpval = query;
5899658991

5899758992
switch (windows.type) {
5899858993
case "window":
5899958994
switch (windows.params[0]) {
5900058995
case "delta":
59001-
curr = query;
5900258996
prev = "lag(" + curr + ") OVER (" + over + ")";
5900358997
query = curr + " - " + prev;
5900458998
break;
5900558999

5900659000
case "increase":
59007-
curr = query;
5900859001
prev = "lag(" + curr + ") OVER (" + over + ")";
5900959002
query = "(CASE WHEN " + curr + " >= " + prev + " THEN " + curr + " - " + prev;
5901059003
query += " WHEN " + prev + " IS NULL THEN NULL ELSE " + curr + " END)";
@@ -59017,7 +59010,6 @@ function () {
5901759010
timeColumn = "min(" + timeColumn + ")";
5901859011
}
5901959012

59020-
curr = query;
5902159013
prev = "lag(" + curr + ") OVER (" + over + ")";
5902259014
query = "(CASE WHEN " + curr + " >= " + prev + " THEN " + curr + " - " + prev;
5902359015
query += " WHEN " + prev + " IS NULL THEN NULL ELSE " + curr + " END)";
@@ -61756,19 +61748,25 @@ function () {
6175661748
};
6175761749
}
6175861750

61751+
var res = null;
61752+
6175961753
if (format === "time_series") {
61760-
return ResponseParser._toTimeSeries(results);
61754+
res = ResponseParser._toTimeSeries(results);
6176161755
}
6176261756

6176361757
if (format === "table") {
61764-
return ResponseParser._toTable(results);
61758+
res = ResponseParser._toTable(results);
6176561759
}
6176661760

6176761761
if (format === "var") {
61768-
return ResponseParser._toVar(results);
61762+
res = ResponseParser._toVar(results);
6176961763
}
6177061764

61771-
return [];
61765+
if (res === null) {
61766+
res = [];
61767+
}
61768+
61769+
return res;
6177261770
};
6177361771

6177461772
ResponseParser._convertValues = function (v, type) {
@@ -61986,7 +61984,6 @@ function () {
6198661984
ResponseParser.prototype.transformAnnotationResponse = function (options, data) {
6198761985
var table = data.data;
6198861986
var timeColumnIndex = -1;
61989-
var titleColumnIndex = -1;
6199061987
var textColumnIndex = -1;
6199161988
var tagsColumnIndex = -1;
6199261989

dist/module.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/bigquery_query.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ export default class BigQueryQuery {
280280
g.type === "hll_count.merge" || g.type === "hll_count.extract"
281281
);
282282
const alias = _.find(column, (g: any) => g.type === "alias");
283+
numOfColumns += 1;
283284
if (hll) {
284-
numOfColumns += 1;
285285
if (hll.type === "hll_count.merge") {
286286
hllInd = numOfColumns;
287287
}
@@ -290,7 +290,6 @@ export default class BigQueryQuery {
290290
query += " AS " + alias.params[0];
291291
}
292292
} else {
293-
numOfColumns += 1;
294293
if (alias) {
295294
query += ",\n" + alias.params[0];
296295
} else {
@@ -343,8 +342,6 @@ export default class BigQueryQuery {
343342
);
344343
if (hll !== undefined) {
345344
this.hll = hll;
346-
}
347-
if (hll !== undefined) {
348345
return (
349346
"HLL_COUNT.INIT (CAST(" +
350347
columnName.params[0] +
@@ -365,19 +362,17 @@ export default class BigQueryQuery {
365362
}
366363
overParts.push("ORDER BY " + this.buildTimeColumn(false));
367364
const over = overParts.join(" ");
368-
let curr: string;
365+
let curr = query;
369366
let prev: string;
370367
const tmpval = query;
371368
switch (windows.type) {
372369
case "window":
373370
switch (windows.params[0]) {
374371
case "delta":
375-
curr = query;
376372
prev = "lag(" + curr + ") OVER (" + over + ")";
377373
query = curr + " - " + prev;
378374
break;
379375
case "increase":
380-
curr = query;
381376
prev = "lag(" + curr + ") OVER (" + over + ")";
382377
query =
383378
"(CASE WHEN " +
@@ -396,8 +391,6 @@ export default class BigQueryQuery {
396391
if (aggregate) {
397392
timeColumn = "min(" + timeColumn + ")";
398393
}
399-
400-
curr = query;
401394
prev = "lag(" + curr + ") OVER (" + over + ")";
402395
query =
403396
"(CASE WHEN " +

src/response_parser.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,20 @@ export default class ResponseParser {
5858
if (!results.rows) {
5959
return { data: [] };
6060
}
61+
let res = null;
6162
if (format === "time_series") {
62-
return ResponseParser._toTimeSeries(results);
63+
res = ResponseParser._toTimeSeries(results);
6364
}
6465
if (format === "table") {
65-
return ResponseParser._toTable(results);
66+
res = ResponseParser._toTable(results);
6667
}
6768
if (format === "var") {
68-
return ResponseParser._toVar(results);
69+
res = ResponseParser._toVar(results);
6970
}
70-
return [];
71+
if (res === null) {
72+
res = [];
73+
}
74+
return res;
7175
}
7276

7377
public static _convertValues(v, type) {
@@ -137,7 +141,6 @@ export default class ResponseParser {
137141
}
138142
return res;
139143
}
140-
141144
private static _toTimeSeries(results) {
142145
let timeIndex = -1;
143146
let metricIndex = -1;
@@ -272,7 +275,6 @@ export default class ResponseParser {
272275
public transformAnnotationResponse(options, data) {
273276
const table = data.data;
274277
let timeColumnIndex = -1;
275-
const titleColumnIndex = -1;
276278
let textColumnIndex = -1;
277279
let tagsColumnIndex = -1;
278280
for (let i = 0; i < data.data.schema.fields.length; i++) {

0 commit comments

Comments
 (0)