refactor: Replace hardcoded date cycle logic#596
Merged
dricazenck merged 5 commits intoWomen-Coding-Community:mainfrom Apr 2, 2026
Merged
Conversation
MentorshipService previously determined the active cycle using London-timezone date windows hard-coded to specific months and day counts. Replace this with a cycleRepository.findOpenCycle() call so cycle state is driven by the database. MenteeService is simplified to use the same repository directly, removing the backward-compatibility fallback. Add @JsonIgnoreProperties to DTO classes to tolerate unknown fields. Tests updated throughout.
The daysCycleOpen property and DEFAULT_DAYS constant are no longer used now that cycle state is DB-driven. Remove the field from MentorshipConfig, drop the property from application.yml, and delete the two daysCycleOpen tests from MentorshipConfigTest. Clean up dead MentorshipConfig and MentorshipService mocks from MenteeServiceTest, and remove the leftover unused daysOpen variable from MentorshipServiceTest setUp.
womencodingcommunity
approved these changes
Apr 2, 2026
Contributor
womencodingcommunity
left a comment
There was a problem hiding this comment.
Solid refactor — removing the London-timezone date windows in favour of a DB-driven open cycle makes the system much more predictable and operationally controllable. The simplification to MenteeService is clean and the dead-code cleanup is thorough. Two optional quick-wins worth addressing: a redundant null ternary in toOpenCycleValue() and a copy-paste Javadoc on getOpenCycle(). The cycleYear field on MenteeRegistration being silently ignored is worth a follow-up but not a blocker.
In toOpenCycleValue(), the expression 'cycleMonth != null ? cycleMonth : null' is equivalent to just 'cycleMonth' — remove the redundant ternary. Fix the copy-pasted Javadoc on getOpenCycle() which incorrectly described the removed getMentorshipCycle() parameters instead of the actual no-arg signature.
Move Jackson unknown-property tolerance from per-class @JsonIgnoreProperties annotations to a single global DeserializationFeature configuration in ObjectMapperConfig, reducing annotation noise and ensuring consistent deserialization behaviour across all DTOs.
Remove unused getOpenCycle() from MentorshipService as no callers remain. Remove the unknown-field-causes-400 controller test now that FAIL_ON_UNKNOWN_PROPERTIES is globally disabled in ObjectMapperConfig.
|
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.



Description
MentorshipService.getCurrentCycle()previously used hard-codedLondon-timezone date windows to determine the active cycle; replaced
with
cycleRepository.findOpenCycle()so cycle state is database-driven.MenteeServicesimplified to query the open cycle directly, removingthe backward-compatibility fallback path.
@JsonIgnoreProperties(ignoreUnknown = true)toMentorDto,MemberDto, andMentorFilterSectionto tolerate unknown JSON fields.Change Type