time zones fix for alarms
This commit is contained in:
parent
49cce92ffe
commit
bb257a1726
16
server.js
16
server.js
@ -206,7 +206,7 @@ async function index(req, res) {
|
|||||||
|
|
||||||
const last11DaysQuery = `
|
const last11DaysQuery = `
|
||||||
WITH date_sequence AS (
|
WITH date_sequence AS (
|
||||||
SELECT DATE_TRUNC('day', NOW() - INTERVAL '10 days' - INTERVAL '3 hours') + (generate_series(0, 10) || ' days')::interval AS day
|
SELECT DATE_TRUNC('day', NOW() - INTERVAL '10 days') + (generate_series(0, 10) || ' days')::interval AS day
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
date_sequence.day AS day,
|
date_sequence.day AS day,
|
||||||
@ -216,8 +216,8 @@ async function index(req, res) {
|
|||||||
SELECT DISTINCT ON (evtuuid) evtuuid, time
|
SELECT DISTINCT ON (evtuuid) evtuuid, time
|
||||||
FROM alarms
|
FROM alarms
|
||||||
WHERE alarmtype = 56
|
WHERE alarmtype = 56
|
||||||
AND time >= NOW() - INTERVAL '11 days' + INTERVAL '3 hours'
|
AND time >= NOW() - INTERVAL '11 days'
|
||||||
AND time <= NOW() + INTERVAL '1 day' + INTERVAL '3 hours'
|
AND time <= NOW() + INTERVAL '1 day'
|
||||||
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
||||||
ORDER BY evtuuid, time DESC
|
ORDER BY evtuuid, time DESC
|
||||||
) AS a ON DATE_TRUNC('day', a.time) = date_sequence.day
|
) AS a ON DATE_TRUNC('day', a.time) = date_sequence.day
|
||||||
@ -228,7 +228,7 @@ async function index(req, res) {
|
|||||||
|
|
||||||
const daysBeforeQuery = `
|
const daysBeforeQuery = `
|
||||||
WITH date_sequence AS (
|
WITH date_sequence AS (
|
||||||
SELECT DATE_TRUNC('day', NOW() - INTERVAL '21 days' - INTERVAL '3 hours') + (generate_series(0, 10) || ' days')::interval AS day
|
SELECT DATE_TRUNC('day', NOW() - INTERVAL '21 days') + (generate_series(0, 10) || ' days')::interval AS day
|
||||||
)
|
)
|
||||||
SELECT
|
SELECT
|
||||||
date_sequence.day AS day,
|
date_sequence.day AS day,
|
||||||
@ -238,8 +238,8 @@ async function index(req, res) {
|
|||||||
SELECT DISTINCT ON (evtuuid) evtuuid, time
|
SELECT DISTINCT ON (evtuuid) evtuuid, time
|
||||||
FROM alarms
|
FROM alarms
|
||||||
WHERE alarmtype = 56
|
WHERE alarmtype = 56
|
||||||
AND time >= NOW() - INTERVAL '21 days' + INTERVAL '3 hours'
|
AND time >= NOW() - INTERVAL '21 days'
|
||||||
AND time <= NOW() + INTERVAL '10 day' + INTERVAL '3 hours'
|
AND time <= NOW() + INTERVAL '10 day'
|
||||||
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
||||||
ORDER BY evtuuid, time DESC
|
ORDER BY evtuuid, time DESC
|
||||||
) AS a ON DATE_TRUNC('day', a.time) = date_sequence.day
|
) AS a ON DATE_TRUNC('day', a.time) = date_sequence.day
|
||||||
@ -270,8 +270,8 @@ async function index(req, res) {
|
|||||||
DATE_TRUNC('day', time) AS day,
|
DATE_TRUNC('day', time) AS day,
|
||||||
CASE WHEN COUNT(*) = 0 THEN 0 ELSE 1 END AS sort_value
|
CASE WHEN COUNT(*) = 0 THEN 0 ELSE 1 END AS sort_value
|
||||||
FROM geo
|
FROM geo
|
||||||
WHERE time >= NOW() - INTERVAL '10 days' + INTERVAL '3 hours'
|
WHERE time >= NOW() - INTERVAL '10 days'
|
||||||
AND time <= NOW() + INTERVAL '1 day' + INTERVAL '3 hours'
|
AND time <= NOW() + INTERVAL '1 day'
|
||||||
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
${!templateData.isAdmin ? 'AND serial = ANY($1)' : ''}
|
||||||
GROUP BY DATE_TRUNC('day', time)
|
GROUP BY DATE_TRUNC('day', time)
|
||||||
ORDER BY sort_value DESC, day DESC;
|
ORDER BY sort_value DESC, day DESC;
|
||||||
|
Loading…
Reference in New Issue
Block a user