time fix in SQL requests
This commit is contained in:
parent
bb257a1726
commit
b25c17b7bd
@ -568,13 +568,13 @@ async function live(req, res) {
|
|||||||
LEFT JOIN registrars AS r ON a.serial = r.serial
|
LEFT JOIN registrars AS r ON a.serial = r.serial
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT *,
|
SELECT *,
|
||||||
ROW_NUMBER() OVER (PARTITION BY serial ORDER BY ABS(EXTRACT(EPOCH FROM (time - $1)))) AS row_num
|
ROW_NUMBER() OVER (PARTITION BY serial ORDER BY ABS(EXTRACT(EPOCH FROM (time - NOW())))) AS row_num
|
||||||
FROM geo
|
FROM geo
|
||||||
) AS g ON a.serial = g.serial AND g.row_num = 1
|
) AS g ON a.serial = g.serial AND g.row_num = 1
|
||||||
ORDER BY a.time DESC
|
ORDER BY a.time DESC
|
||||||
LIMIT 100;
|
LIMIT 100;
|
||||||
`;
|
`;
|
||||||
const alarms = await client.query(subquery, templateData.isAdmin ? [new Date()] : [new Date(), serialValues]);
|
const alarms = await client.query(subquery);
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
const options = {
|
const options = {
|
||||||
@ -917,13 +917,13 @@ async function reports(req, res) {
|
|||||||
LEFT JOIN registrars AS r ON a.serial = r.serial
|
LEFT JOIN registrars AS r ON a.serial = r.serial
|
||||||
LEFT JOIN (
|
LEFT JOIN (
|
||||||
SELECT *,
|
SELECT *,
|
||||||
ROW_NUMBER() OVER (PARTITION BY serial ORDER BY ABS(EXTRACT(EPOCH FROM (time - $1)))) AS row_num
|
ROW_NUMBER() OVER (PARTITION BY serial ORDER BY ABS(EXTRACT(EPOCH FROM (time - NOW())))) AS row_num
|
||||||
FROM geo
|
FROM geo
|
||||||
) AS g ON a.serial = g.serial AND g.row_num = 1
|
) AS g ON a.serial = g.serial AND g.row_num = 1
|
||||||
ORDER BY a.time DESC
|
ORDER BY a.time DESC
|
||||||
LIMIT 100;
|
LIMIT 100;
|
||||||
`;
|
`;
|
||||||
const alarms = await client.query(query, templateData.isAdmin ? [new Date()] : [new Date(), serialValues]);
|
const alarms = await client.query(query);
|
||||||
|
|
||||||
function formatDate(date) {
|
function formatDate(date) {
|
||||||
const options = {
|
const options = {
|
||||||
|
Loading…
Reference in New Issue
Block a user