Skip to content

Conversation

@tjementum
Copy link
Member

@tjementum tjementum commented Jan 7, 2026

Summary & Motivation

Add a dedicated LastSeenAt property to the User entity to accurately track when users were last active, replacing the unreliable ModifiedAt field which changes on any user update (role changes, profile edits, etc.). This provides meaningful activity data for the "Active users" dashboard metric, which now correctly counts users with activity within the last 30 days.

  • Add LastSeenAt nullable property to User entity, updated during login, token refresh, tenant switch, and signup completion
  • Create database schema migration to add the LastSeenAt column
  • Introduce the first data migration using IDataMigration to populate existing confirmed users with their ModifiedAt or CreatedAt values
  • Update user management UI to display "Last seen" instead of "Modified" in both the user table and profile side pane
  • Change the GetUserSummary query to use LastSeenAt for calculating active users instead of ModifiedAt
  • Add backend test for user summary to verify active user counting based on LastSeenAt
  • Add E2E test coverage to verify LastSeenAt is preserved during role changes and user restore operations

This is the first usage of IDataMigration in PlatformPlatform. Unlike schema migrations which run during CI/CD before code deployment (requiring old code to work with the new schema), data migrations run when the Worker starts after deployment. Since API and Worker deploy in parallel with independent rolling updates, old API instances may still write data after the data migration completes, so data migrations should be designed to handle this timing window.

Checklist

  • I have added tests, or done manual regression tests
  • I have updated the documentation, if necessary

@tjementum tjementum self-assigned this Jan 7, 2026
@tjementum tjementum added the Enhancement New feature or request label Jan 7, 2026
@linear
Copy link

linear bot commented Jan 7, 2026

@tjementum tjementum moved this to 🏗 In Progress in Kanban board Jan 7, 2026
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 7, 2026

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Approve Database Migration account-management database on stage

The following pending migration(s) will be applied to the database when approved:

  • AddUserLastSeenAt (20260106160000_AddUserLastSeenAt)

Migration Script

BEGIN TRANSACTION;
IF NOT EXISTS (
    SELECT * FROM [__EFMigrationsHistory]
    WHERE [MigrationId] = N'20260106160000_AddUserLastSeenAt'
)
BEGIN
    ALTER TABLE [Users] ADD [LastSeenAt] datetimeoffset NULL;
END;

IF NOT EXISTS (
    SELECT * FROM [__EFMigrationsHistory]
    WHERE [MigrationId] = N'20260106160000_AddUserLastSeenAt'
)
BEGIN
    INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
    VALUES (N'20260106160000_AddUserLastSeenAt', N'10.0.1');
END;

COMMIT;
GO

@tjementum tjementum merged commit 5555b42 into main Jan 7, 2026
16 checks passed
@tjementum tjementum deleted the pp-751-tast-last-seen-on-user-and-display-in-user-overview branch January 7, 2026 22:02
@github-project-automation github-project-automation bot moved this from 🏗 In Progress to ✅ Done in Kanban board Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant