SCRUM-389 refactor(schedules): split apply-template handler into focused services - #365
Closed
Mahmoud-Alim wants to merge 1 commit into
Closed
Mahmoud-Alim wants to merge 1 commit into
Mahmoud-Alim wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Automated PR Validation FeedbackAction Needed on this Pull Request:
Please push a fix to your branch to re-run validation! |
Automated PR Validation FeedbackAction Needed on this Pull Request:
Please push a fix to your branch to re-run validation! |
Mahmoud-Alim
force-pushed
the
refactor/apply-template-focused-services
branch
from
September 15, 2026 21:44
47fa023 to
adcf642
Compare
Automated PR Validation FeedbackAction Needed on this Pull Request:
Please push a fix to your branch to re-run validation! |
1 similar comment
Automated PR Validation FeedbackAction Needed on this Pull Request:
Please push a fix to your branch to re-run validation! |
Owner
|
Declined: Adds excessive abstraction layers (5 new interfaces/classes for a single handler) and introduces specification pattern boilerplate. Existing CQRS handlers with direct repository/EF LINQ are simpler, more direct, and keep cognitive overhead low. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ApplyTemplateCommandHandlergrew into an 876-line god handler with 10 dependencies(availability + strip rules + overlap detection + keep policy + pricing + coverage
in one class). This PR extracts the logic into 5 focused services behind interfaces,
leaving the handler as a thin orchestrator (~169 lines, 5 dependencies).
No behavior change: same command, same response DTO, same strip/collision codes.
What Changed
Application Layer
Features/Schedules/ApplyTemplate/Services/:ITemplateApplicationLoader(all data loading + persistence),IAvailabilityResolver(site authorization, operational hours, leave/remote),IEligibilityEvaluator(pure strip-rule evaluation, zero dependencies),IScheduleAnalyticsService(pure labor-cost + coverage calculation),IOverlapResolver(overlap detection + keep-new/keep-existing policy).ApplyTemplateCommandHandlernow only orchestrates: validate → load →availability → eligibility → overlaps → persist → analytics → response.
Response mapping (
BuildResponse/MapBlock) intentionally stays in the handler.PlannedBlock,AvailabilityContext,KeepMode) promoted tostandalone files. Backward-compatible obsolete constructor kept for transition.
Application/DependencyInjection.cs.Testing
ApplyTemplateTests(19 tests) updated to compose the newservices; all pass. Full
Schedulessuite (186 tests) passes.overtime pricing, and coverage status.
Backward Compatibility
ApplyTemplateCommandandApplyTemplateResponseDtoare unchanged.Existing API clients are unaffected.
Important Implementation Details
main,because the extracted services already use the specification-based repository API
introduced in the follow-up branch
refactor/decouple-application-from-ef-core.Merge this PR first, then the follow-up immediately after — or stack the
follow-up onto this branch.
EligibilityEvaluatorandScheduleAnalyticsServiceare pure (no repositories)and are the best candidates for direct unit tests going forward.
Checklist