-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ChartMetaActions Fucntion for Querying by Truncated Timestamps
give it: - a chart - a truncation span ("minutes", "hours", "days", etc) - (optional) time span - (optional) bbox and you get aggregated data for the truncated timestamps Updates #264
- Loading branch information
Vince Forgione
committed
Apr 4, 2018
1 parent
259c44a
commit 81804a8
Showing
3 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
SELECT | ||
DATE_TRUNC('<%= ts_trunc_span %>', "<%= chart.timestamp_field %>") AS "<%= chart.timestamp_field %>" | ||
<%= for {path, field} <- data_fields do %> | ||
, <%= chart.data_agg_func %>((<%= field %>)::numeric)::float AS "<%= path %>" | ||
<% end %> | ||
FROM | ||
"<%= table_name %>" | ||
<%= if ts_range != nil or bbox != nil do %> | ||
WHERE | ||
<%= if ts_range != nil do %> | ||
'<%= ts_range %>'::tstzrange @> "<%= chart.timestamp_field %>" | ||
<%= if bbox != nil do %> | ||
AND | ||
<% end %> | ||
<% end %> | ||
<%= if bbox != nil do %> | ||
ST_CONTAINS('<%= bbox %>'::geometry, "<%= chart.location_field %>") | ||
<% end %> | ||
<% end %> | ||
GROUP BY | ||
"<%= chart.timestamp_field %>" | ||
ORDER BY | ||
"<%= chart.timestamp_field %>" | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters