Use template string for dateOverrideBasicsQueryTpl

This commit is contained in:
Daniel García Aubert 2017-09-06 10:57:38 +02:00
parent 0b79ac76db
commit 0ede3013db

View File

@ -210,25 +210,25 @@ const dateBasicsQueryTpl = ctx => `
)
`;
var dateOverrideBasicsQueryTpl = dot.template([
'__cdb_basics AS (',
' SELECT',
' max({{=it._end}}) AS __cdb_max_val,',
' min({{=it._start}}) AS __cdb_min_val,',
' avg(date_part(\'epoch\', {{=it._column}})) AS __cdb_avg_val,',
' min(',
' date_trunc(',
' \'{{=it._aggregation}}\',',
' TO_TIMESTAMP({{=it._start}})::timestamp AT TIME ZONE \'{{=it._offset}}\'',
' )',
' ) AS __cdb_start_date,',
' max(',
' TO_TIMESTAMP({{=it._end}})::timestamp AT TIME ZONE \'{{=it._offset}}\'',
' ) AS __cdb_end_date,',
' count(1) AS __cdb_total_rows',
' FROM ({{=it._query}}) __cdb_basics_query',
')'
].join(' \n'));
const dateOverrideBasicsQueryTpl = ctx => `
__cdb_basics AS (
SELECT
max(${ctx._end}) AS __cdb_max_val,
min(${ctx._start}) AS __cdb_min_val,
avg(date_part('epoch', ${ctx._column})) AS __cdb_avg_val,
min(
date_trunc(
'${ctx._aggregation}',
TO_TIMESTAMP(${ctx._start})::timestamp AT TIME ZONE '${ctx._offset}'
)
) AS __cdb_start_date,
max(
TO_TIMESTAMP(${ctx._end})::timestamp AT TIME ZONE '${ctx._offset}'
) AS __cdb_end_date,
count(1) AS __cdb_total_rows
FROM (${ctx._query}) __cdb_basics_query
)
`;
var dateBinsQueryTpl = dot.template([
'__cdb_bins AS (',