Fix timezone display: client uses server timezone from settings, revert SQL offset
This commit is contained in:
1 parent
3653016912
commit
28e3c6a544
8 files changed
+25
-118
No files matched your search
+4
-8
@@ -230,9 +230,8 @@ app.get('/api/dashboard', (req, res) => {
|
||||
WHERE resource_id = ? AND resolved_at IS NULL
|
||||
`).get(resource.id);
|
||||
|
||||
const tzOffset = getTimezoneOffset();
|
||||
const recentChecks = db.prepare(`
|
||||
SELECT response_time, status, datetime(checked_at, '${tzOffset}') as checked_at
|
||||
SELECT response_time, status, checked_at
|
||||
FROM checks
|
||||
WHERE resource_id = ?
|
||||
ORDER BY checked_at DESC
|
||||
@@ -455,7 +454,6 @@ app.get('/api/resources/:id/history', (req, res) => {
|
||||
WHERE resource_id = ? AND checked_at > datetime('now', ?)
|
||||
`).get(id, `-${days} days`);
|
||||
|
||||
const tzOffset = getTimezoneOffset();
|
||||
const checks = db.prepare(`
|
||||
SELECT
|
||||
id,
|
||||
@@ -464,7 +462,7 @@ app.get('/api/resources/:id/history', (req, res) => {
|
||||
status_code,
|
||||
error_message,
|
||||
details,
|
||||
datetime(checked_at, '${tzOffset}') as checked_at
|
||||
checked_at
|
||||
FROM checks
|
||||
WHERE resource_id = ? AND checked_at > datetime('now', ?)
|
||||
ORDER BY checked_at DESC
|
||||
@@ -541,11 +539,10 @@ app.get('/api/history/overview', (req, res) => {
|
||||
// Use a reliable bucketing approach with Julian Day Numbers
|
||||
// Convert to julian day, multiply by 24 for hours, divide by intervalHours and round
|
||||
const bucketExpr = `ROUND((julianday(checked_at) * 24) / ${intervalHours}) * ${intervalHours} / 24`;
|
||||
const tzOffset = getTimezoneOffset();
|
||||
|
||||
recentChecks = db.prepare(`
|
||||
SELECT
|
||||
datetime(${bucketExpr}, '${tzOffset}') AS checked_at,
|
||||
datetime(${bucketExpr}) AS checked_at,
|
||||
AVG(CASE WHEN status='up' THEN response_time ELSE NULL END) AS avg_up_response,
|
||||
SUM(CASE WHEN status='up' THEN 1 ELSE 0 END) AS up_count,
|
||||
COUNT(*) AS total_count
|
||||
@@ -562,9 +559,8 @@ app.get('/api/history/overview', (req, res) => {
|
||||
} else {
|
||||
console.log(`Using non-averaged mode for ${resource.name}`);
|
||||
// Non-averaged: filter to window but cap to last 600 checks
|
||||
const tzOffset = getTimezoneOffset();
|
||||
recentChecks = db.prepare(`
|
||||
SELECT status, response_time, datetime(checked_at, '${tzOffset}') as checked_at
|
||||
SELECT status, response_time, checked_at
|
||||
FROM checks
|
||||
WHERE resource_id = ? AND checked_at > datetime('now', ?)
|
||||
ORDER BY checked_at DESC
|
||||
|
||||
Reference in new issue
Block a user