fix(analytics): show per-student last seen from login and session activity (#674)

* fix(analytics): show per-student last seen from login and session activity

Return ISO last-seen timestamps from course analytics instead of
pre-formatted strings so the dashboard can format them per student.
Batch-fetch last seen for all students and include session activity
alongside login events for more accurate, distinct values.

Co-authored-by: Rotimi Best <[email protected]>

* fix(analytics): destructure first row from getLastLogin query results

Promise.all returns an array per Drizzle select; nested destructuring
is required so loggedInAt and updatedAt are read from row objects.

Co-authored-by: Rotimi Best <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Rotimi Best <[email protected]>
This commit is contained in:
Rotimi Best
2026-06-23 10:09:47 +01:00
committed by GitHub
co-authored by Rotimi Best Cursor Agent
parent bbdb2e9419
commit f2d7afc590
4 changed files with 121 additions and 22 deletions
@@ -8,6 +8,7 @@
import * as Table from '@cio/ui/base/table';
import { courseApi } from '$features/course/api';
import { calDateDiff } from '$lib/utils/functions/date';
import { t } from '$lib/utils/functions/translations';
import EmptyState from './empty-state.svelte';
@@ -125,7 +126,7 @@
</Table.Cell>
<Table.Cell class="min-w-[120px] px-4 py-3">
<span class="ui:text-muted-foreground text-sm">
{student.lastSeen}
{student.lastSeen ? calDateDiff(student.lastSeen) : $t('analytics.a_while_ago')}
</span>
</Table.Cell>
<Table.Cell class="min-w-[120px] px-4 py-3">
@@ -21,7 +21,7 @@ export interface StudentOverview {
exercisesSubmitted: number;
totalExercises: number;
averageGrade: number;
lastSeen: string;
lastSeen: string | undefined;
progressPercentage: number;
}