Mobile desighn Adjustments
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user