fix: correct last-sync date and logout redirect issues
- Fix admin users last-sync showing 1970 instead of actual sync date - Changed from MAX(qsos.createdAt) to MAX(syncJobs.completedAt) - Added timestamp conversion (seconds to milliseconds) for proper Date serialization - Fix logout redirect not working from admin dashboard - Changed from goto() to window.location.href for hard redirect - Ensures proper navigation after auth state changes Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -127,7 +127,12 @@ export async function getUserStats() {
|
||||
lotwConfirmed: sql`CAST(SUM(CASE WHEN ${qsos.lotwQslRstatus} = 'Y' THEN 1 ELSE 0 END) AS INTEGER)`,
|
||||
dclConfirmed: sql`CAST(SUM(CASE WHEN ${qsos.dclQslRstatus} = 'Y' THEN 1 ELSE 0 END) AS INTEGER)`,
|
||||
totalConfirmed: sql`CAST(SUM(CASE WHEN ${qsos.lotwQslRstatus} = 'Y' OR ${qsos.dclQslRstatus} = 'Y' THEN 1 ELSE 0 END) AS INTEGER)`,
|
||||
lastSync: sql`MAX(${qsos.createdAt})`,
|
||||
lastSync: sql`(
|
||||
SELECT MAX(${syncJobs.completedAt})
|
||||
FROM ${syncJobs}
|
||||
WHERE ${syncJobs.userId} = ${users.id}
|
||||
AND ${syncJobs.status} = 'completed'
|
||||
)`.mapWith(Number),
|
||||
createdAt: users.createdAt,
|
||||
})
|
||||
.from(users)
|
||||
@@ -135,7 +140,11 @@ export async function getUserStats() {
|
||||
.groupBy(users.id)
|
||||
.orderBy(sql`COUNT(${qsos.id}) DESC`);
|
||||
|
||||
return stats;
|
||||
// Convert lastSync timestamps (seconds) to Date objects for JSON serialization
|
||||
return stats.map(stat => ({
|
||||
...stat,
|
||||
lastSync: stat.lastSync ? new Date(stat.lastSync * 1000) : null,
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user