Mobile desighn Adjustments

This commit is contained in:
2025-09-05 12:37:33 +02:00
parent 00849e6d15
commit 3872397082
8 changed files with 918 additions and 231 deletions

View File

@@ -83,18 +83,17 @@ router.get('/times-with-details', async (req, res) => {
locationFilter = `AND l.name ILIKE '%${location}%'`;
}
// Build WHERE clause for date filter
// Build WHERE clause for date filter using PostgreSQL timezone functions
let dateFilter = '';
const now = new Date();
if (period === 'today') {
const today = now.toISOString().split('T')[0];
dateFilter = `AND DATE(t.created_at) = '${today}'`;
// Today in local timezone (UTC+2)
dateFilter = `AND DATE(t.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Berlin') = CURRENT_DATE`;
} else if (period === 'week') {
const weekAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
dateFilter = `AND DATE(t.created_at) >= '${weekAgo}'`;
// This week starting from Monday in local timezone
dateFilter = `AND DATE(t.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Berlin') >= DATE_TRUNC('week', CURRENT_DATE)`;
} else if (period === 'month') {
const monthAgo = new Date(now.getFullYear(), now.getMonth(), 1).toISOString().split('T')[0];
dateFilter = `AND DATE(t.created_at) >= '${monthAgo}'`;
// This month starting from 1st in local timezone
dateFilter = `AND DATE(t.created_at AT TIME ZONE 'UTC' AT TIME ZONE 'Europe/Berlin') >= DATE_TRUNC('month', CURRENT_DATE)`;
}
// Get all times with player and location details, ordered by time (fastest first)