fix(activity): leave soft-deleted rows out of the MikroORM daily aggregations
Problem
The MikroORM daily activity aggregations (getDailyActivities, getDailyActivitiesReport) run raw knex, which skips MikroORM's soft-delete filter. Time slots are soft-deleted by default, so the activities of a deleted slot (and deleted activities) were still counted in sessions and duration; TypeORM leaves them out.
Fix
whereNull on activity.deletedAt, employee.deletedAt and time_slot.deletedAt in both queries.
Tests
New activity.service.mikro-orm-soft-deleted.spec.ts on an in-memory SQLite store: only the live activity is counted by both methods. The fixture tables of activity.service.employee-scope.spec.ts gain the deletedAt column.
Notes
Not built or run locally.
Summary by cubic
Fixes the MikroORM daily activity aggregations so activities of soft-deleted rows are no longer counted. The queries run on raw knex, which skips MikroORM's soft-delete filter, so activities from a deleted time slot (time slots are soft-deleted by default), of a deleted employee, and deleted activities were still counted in sessions and duration; TypeORM leaves them out.
Bug Fixes
- Filters on
activity.deletedAt,employee.deletedAt, andtime_slot.deletedAtin bothgetDailyActivitiesandgetDailyActivitiesReport. - Adds
activity.service.mikro-orm-soft-deleted.spec.tscovering filtered activities, the deleted slot, and a deleted employee; the employee-scope spec fixtures gain thedeletedAtcolumn. - Not built or run locally.