Skip to content

Commit

Permalink
fixed time series endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasholderness committed Jan 22, 2018
1 parent b24a6cd commit 15c7bca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ API Server for CogniCity
* Updated documentation of Swagger files
* Updated Babel package
* Remove username field from GET /cards/:id
* Fix bug with time series endpoints
4 changes: 2 additions & 2 deletions src/api/routes/floods/timeseries/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default (config, db, logger) => ({
// Setup query
let query = `SELECT ts, count(local_area) FROM
(SELECT (cognicity.rem_get_flood(ts)).local_area, ts
FROM generate_series($1::timestamp with time zone,
$2::timestamp with time zone,'1 hour')
FROM generate_series(date_trunc('hour', $1::timestamp with time zone),
date_trunc('hour', $2::timestamp with time zone),'1 hour')
as series(ts)) output
GROUP BY ts ORDER BY ts`;

Expand Down
4 changes: 2 additions & 2 deletions src/api/routes/reports/timeseries/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default (config, db, logger) => ({
count: (start, end, city) => new Promise((resolve, reject) => {
// Setup query
let query = `SELECT ts, count(r.pkey)
FROM generate_series($1::timestamp with time zone,
$2::timestamp with time zone, '1 hour') ts
FROM generate_series(date_trunc('hour', $1::timestamp with time zone),
date_trunc('hour', $2::timestamp with time zone), '1 hour') ts
LEFT JOIN cognicity.all_reports r
ON date_trunc('hour', r.created_at) = ts
AND ($3 IS NULL OR tags->>'instance_region_code'=$3)
Expand Down

0 comments on commit 15c7bca

Please sign in to comment.