Merge remote-tracking branch 'origin/development'
This commit is contained in:
commit
b500496176
@ -162,7 +162,7 @@ def dashboard():
|
|||||||
if session['timeframe'] == 'last24hours':
|
if session['timeframe'] == 'last24hours':
|
||||||
# Group by hour: substr(timestamp, 12, 2) -> HH
|
# Group by hour: substr(timestamp, 12, 2) -> HH
|
||||||
query = f'''
|
query = f'''
|
||||||
SELECT substr(timestamp, 12, 2) AS bucket, COUNT(DISTINCT device_id) AS count
|
SELECT substr(timestamp, 1, 13) AS bucket, COUNT(DISTINCT device_id) AS count
|
||||||
FROM file_access_log
|
FROM file_access_log
|
||||||
WHERE timestamp >= ? {filetype_filter_sql}
|
WHERE timestamp >= ? {filetype_filter_sql}
|
||||||
GROUP BY bucket
|
GROUP BY bucket
|
||||||
@ -207,7 +207,7 @@ def dashboard():
|
|||||||
if session['timeframe'] == 'last24hours':
|
if session['timeframe'] == 'last24hours':
|
||||||
# Hour: substr(timestamp, 12, 2) -> HH
|
# Hour: substr(timestamp, 12, 2) -> HH
|
||||||
query = f'''
|
query = f'''
|
||||||
SELECT substr(timestamp, 12, 2) AS bucket, COUNT(*) AS count
|
SELECT substr(timestamp, 1, 13) AS bucket, COUNT(*) AS count
|
||||||
FROM file_access_log
|
FROM file_access_log
|
||||||
WHERE timestamp >= ? {filetype_filter_sql}
|
WHERE timestamp >= ? {filetype_filter_sql}
|
||||||
GROUP BY bucket
|
GROUP BY bucket
|
||||||
|
|||||||
@ -216,15 +216,22 @@
|
|||||||
const timeframe = "{{ timeframe }}"; // e.g., 'last24hours', '7days', '30days', or '365days'
|
const timeframe = "{{ timeframe }}"; // e.g., 'last24hours', '7days', '30days', or '365days'
|
||||||
const shiftedLabels = timeframeData.map(item => {
|
const shiftedLabels = timeframeData.map(item => {
|
||||||
if (timeframe === 'last24hours') {
|
if (timeframe === 'last24hours') {
|
||||||
// For 'last24hours', the bucket is an hour in local time (e.g., "14")
|
// item.bucket will be something like "2025-04-01T15"
|
||||||
const localHour = parseInt(item.bucket, 10);
|
const bucketDate = new Date(item.bucket + ":00:00"); // Convert to a full datetime by appending minutes and seconds.
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
// Use local date components since the timestamp is already local
|
|
||||||
const localStart = new Date(now.getFullYear(), now.getMonth(), now.getDate(), localHour);
|
// Check if this bucket corresponds to the current hour
|
||||||
const localEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), localHour + 1);
|
const isCurrentHour =
|
||||||
return `${localStart.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${localEnd.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
|
bucketDate.getFullYear() === now.getFullYear() &&
|
||||||
|
bucketDate.getMonth() === now.getMonth() &&
|
||||||
|
bucketDate.getDate() === now.getDate() &&
|
||||||
|
bucketDate.getHours() === now.getHours();
|
||||||
|
|
||||||
|
// If it is the current hour, use the current time as the end; otherwise, add one hour.
|
||||||
|
const bucketEnd = isCurrentHour ? now : new Date(bucketDate.getTime() + 3600 * 1000);
|
||||||
|
|
||||||
|
return `${bucketDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${bucketEnd.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`;
|
||||||
} else if (timeframe === '7days' || timeframe === '30days') {
|
} else if (timeframe === '7days' || timeframe === '30days') {
|
||||||
// For these timeframes, assume the bucket is already in local date format
|
|
||||||
const localDate = new Date(item.bucket);
|
const localDate = new Date(item.bucket);
|
||||||
return localDate.toLocaleDateString();
|
return localDate.toLocaleDateString();
|
||||||
} else if (timeframe === '365days') {
|
} else if (timeframe === '365days') {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user