Qualify columns and improve if/else style
As suggested by Algunenano: qualify column names with the table/subquery/cte to avoid name clashing, and polish the code style a little.
This commit is contained in:
parent
a1807fd0c3
commit
e247e45f96
@ -101,14 +101,17 @@ module.exports = class NumericHistogram extends BaseHistogram {
|
|||||||
var extra_groupby = ``;
|
var extra_groupby = ``;
|
||||||
var extra_filter = ``;
|
var extra_filter = ``;
|
||||||
|
|
||||||
if (ctx.start >= ctx.end) {
|
if (ctx.start < ctx.end) {
|
||||||
|
extra_filter = `
|
||||||
|
WHERE __ctx_query.${ctx.column} >= ${ctx.start}
|
||||||
|
AND __ctx_query.${ctx.column} <= ${ctx.end}
|
||||||
|
`;
|
||||||
|
} else {
|
||||||
ctx.end = `__cdb_basics.__cdb_max_val`;
|
ctx.end = `__cdb_basics.__cdb_max_val`;
|
||||||
ctx.start = `__cdb_basics.__cdb_min_val`;
|
ctx.start = `__cdb_basics.__cdb_min_val`;
|
||||||
extra_groupby = `, __cdb_basics.__cdb_max_val, __cdb_basics.__cdb_min_val`;
|
extra_groupby = `, __cdb_basics.__cdb_max_val, __cdb_basics.__cdb_min_val`;
|
||||||
extra_tables = `, __cdb_basics`;
|
extra_tables = `, __cdb_basics`;
|
||||||
extra_queries = `WITH ${irqQueryTpl(ctx)}`;
|
extra_queries = `WITH ${irqQueryTpl(ctx)}`;
|
||||||
} else {
|
|
||||||
extra_filter = `WHERE ${ctx.column} >= ${ctx.start} AND ${ctx.column} <= ${ctx.end}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx.bins <= 0) {
|
if (ctx.bins <= 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user