refactor(reporting): enhance timezone handling and clean up migration

- Updated SQL queries in reporting controllers to join with the timezones table for accurate timezone retrieval.
- Refactored ReportingMembersController to extend ReportingControllerBaseWithTimezone for centralized timezone logic.
- Removed obsolete migration file that added a timezone column to the users table, as it is no longer needed.
This commit is contained in:
chamikaJ
2025-07-24 09:25:50 +05:30
parent 69b2fe1a90
commit de26417247
5 changed files with 29 additions and 25 deletions

View File

@@ -12,7 +12,10 @@ export default abstract class ReportingControllerBaseWithTimezone extends Workle
* @returns The user's timezone or 'UTC' as default
*/
protected static async getUserTimezone(userId: string): Promise<string> {
const q = `SELECT timezone FROM users WHERE id = $1`;
const q = `SELECT tz.name as timezone
FROM users u
JOIN timezones tz ON u.timezone_id = tz.id
WHERE u.id = $1`;
const result = await db.query(q, [userId]);
return result.rows[0]?.timezone || 'UTC';
}