Improve readability

This commit is contained in:
Daniel García Aubert 2017-07-12 15:10:39 +02:00
parent 468f641af8
commit 967dca9578

View File

@ -159,11 +159,15 @@ var dateOverrideBasicsQueryTpl = dot.template([
' max({{=it._end}}) AS max_val,', ' max({{=it._end}}) AS max_val,',
' min({{=it._start}}) AS min_val,', ' min({{=it._start}}) AS min_val,',
' avg(date_part(\'epoch\', {{=it._column}})) AS avg_val,', ' avg(date_part(\'epoch\', {{=it._column}})) AS avg_val,',
' min(date_trunc(', ' min(',
' date_trunc(',
' \'{{=it._aggregation}}\',', ' \'{{=it._aggregation}}\',',
' TO_TIMESTAMP({{=it._start}})::timestamp AT TIME ZONE \'{{=it._timezone}}\'', ' TO_TIMESTAMP({{=it._start}})::timestamp AT TIME ZONE \'{{=it._timezone}}\'',
' )) AS start_date,', ' )',
' max(TO_TIMESTAMP({{=it._end}})::timestamp AT TIME ZONE \'{{=it._timezone}}\') AS end_date,', ' ) AS start_date,',
' max(',
' TO_TIMESTAMP({{=it._end}})::timestamp AT TIME ZONE \'{{=it._timezone}}\'',
' ) AS end_date,',
' count(1) AS total_rows', ' count(1) AS total_rows',
' FROM ({{=it._query}}) _cdb_basics', ' FROM ({{=it._query}}) _cdb_basics',
')' ')'
@ -177,15 +181,11 @@ var dateBinsQueryTpl = dot.template([
' FROM (', ' FROM (',
' SELECT', ' SELECT',
' ARRAY(', ' ARRAY(',
' {{?it._aggregation==="quarter"}}',
' SELECT GENERATE_SERIES(start_date::timestamptz, end_date::timestamptz, \'3 month\'::interval)',
' {{??}}',
' SELECT GENERATE_SERIES(', ' SELECT GENERATE_SERIES(',
' start_date::timestamptz,', ' start_date::timestamptz,',
' end_date::timestamptz,', ' end_date::timestamptz,',
' \'1 {{=it._aggregation}}\'::interval', ' {{?it._aggregation==="quarter"}}\'3 month\'{{??}}\'1 {{=it._aggregation}}\'{{?}}::interval',
' )', ' )',
' {{?}}',
' ) AS bins_array', ' ) AS bins_array',
' FROM basics', ' FROM basics',
' ) _cdb_bins_array', ' ) _cdb_bins_array',
@ -207,10 +207,14 @@ var dateHistogramQueryTpl = dot.template([
' bins_number', ' bins_number',
' )) - 1', ' )) - 1',
' END AS bin,', ' END AS bin,',
' min(date_part(', ' min(',
' date_part(',
' \'epoch\', ', ' \'epoch\', ',
' date_trunc(\'{{=it._aggregation}}\', {{=it._column}}::timestamptz', ' date_trunc(',
' ) AT TIME ZONE \'{{=it._timezone}}\'))::numeric AS timestamp,', ' \'{{=it._aggregation}}\', {{=it._column}}::timestamptz',
' ) AT TIME ZONE \'{{=it._timezone}}\'',
' )',
' )::numeric AS timestamp,',
' min(date_part(\'epoch\', {{=it._column}}))::numeric AS min,', ' min(date_part(\'epoch\', {{=it._column}}))::numeric AS min,',
' max(date_part(\'epoch\', {{=it._column}}))::numeric AS max,', ' max(date_part(\'epoch\', {{=it._column}}))::numeric AS max,',
' avg(date_part(\'epoch\', {{=it._column}}))::numeric AS avg,', ' avg(date_part(\'epoch\', {{=it._column}}))::numeric AS avg,',