Add TodoService method for resolving stale MR todos
Goal
Add the core service method for resolving stale todos without any integration points. This is pure business logic with no side effects.
Related to #20637 (closed)
Implementation Details
Code Changes
Add new method to TodoService:
-
Location:
app/services/todo_service.rb -
Method:
resolve_stale_todos_for_merge_request - Logic: Find and resolve specific action types (ASSIGNED, REVIEW_REQUESTED, APPROVAL_REQUIRED, ADDED_APPROVER) for all users
- Note: Synchronous for simplicity at this stage
- EE-safe: Gracefully handle CE vs EE action type differences
Target Action Types
STALE_ON_MR_COMPLETION = [
Todo::ASSIGNED, # 1 - Assignment is no longer actionable
Todo::APPROVAL_REQUIRED, # 5 - (EE) Approval no longer needed
Todo::REVIEW_REQUESTED, # 9 - Review no longer needed
Todo::ADDED_APPROVER # 13 - (EE) Approval no longer needed
].freeze
Excluded types: MENTIONED, DIRECTLY_ADDRESSED (users may want these for context)
Test Coverage Required
Location: spec/services/todo_service_spec.rb
-
Resolves ASSIGNED todos for multiple users -
Resolves REVIEW_REQUESTED todos -
Does NOT resolve MENTIONED todos -
Does NOT resolve DIRECTLY_ADDRESSED todos -
Works when MR is merged -
Works when MR is closed -
Does NOT resolve when MR is still open -
Updates user todo count caches -
Works in CE (without EE action types) -
Works in EE (with APPROVAL_REQUIRED and ADDED_APPROVER) -
Handles empty results gracefully
Files to Change
-
app/services/todo_service.rb(add method) -
spec/services/todo_service_spec.rb(add tests) -
ee/spec/services/ee/todo_service_spec.rb(add EE-specific tests)
Acceptance Criteria
-
Method resolves only target action types -
Method ignores mention/address todos -
Method updates user todo count caches -
Method works in both CE and EE -
100% test coverage for new method -
No performance regressions in existing todo specs -
Code review approved -
All CI jobs pass
Notes
- This MR contains "dead code" until Phase 1b/1c hook it up
- Safe to merge and deploy immediately
- Provides foundation for following phases
- No user-facing changes
Estimated Effort: 2-3 days