-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rewrite logic of habit status computation #4
Conversation
refactor routine to habit; use HabitStatus instead of HistoricalStatus and PlanningStatus; add additional statuses for clarity; rewrite logic of habit status computation so that both: historical and future statuses can be computed on the go instead of being cashed in the database, the only data that needs to be stored is number of times completed;
@CodiumAI-Agent /review |
PR Analysis
PR Feedback
How to useInstructions
|
@CodiumAI-Agent /ask Is it reasonable to split this PR into smaller parts? And what parts exactly? |
Question: Is it reasonable to split this PR into smaller parts? And what parts exactly? Answer:
By splitting the PR in this way, each PR would have a clear, focused purpose, making it easier to review and understand. |
/describe |
PR Description updated to latest commit (61698b6) |
update_changelog |
Changelog updates: 2023-12-20Changed
|
/update_changelog --pr_update_changelog.push_changelog_changes=true |
## 2023-12-20 | ||
|
||
### Changed | ||
- Rewrite logic of habit status computation | ||
- Refactor routine to habit | ||
- Use HabitStatus instead of HistoricalStatus and PlanningStatus | ||
- Add additional statuses for clarity | ||
- Rewrite logic of habit status computation so that both historical and future statuses can be computed on the go instead of being cached in the database. The only data that needs to be stored is the number of times completed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CHANGELOG.md update
@CodiumAI-Agent /improve |
PR Code Suggestions💡 Suggestion: Rename the variable 'routineStartDate' to 'habitStartDate' to match the new naming convention. Example code:Existing code: val schedule: Schedule = Schedule.EveryDaySchedule(
startDate = routineStartDate,
) Improved code: val schedule: Schedule = Schedule.EveryDaySchedule(
startDate = habitStartDate,
) 💡 Suggestion: Rename the variable 'routineId' to 'habitId' to match the new naming convention. Example code:Existing code: val previousStreak = streakRepository.getStreakByDate(
routineId = habit.id!!,
dateWithinStreak = date.minus(DatePeriod(days = 1)),
) Improved code: val previousStreak = streakRepository.getStreakByDate(
habitId = habit.id!!,
dateWithinStreak = date.minus(DatePeriod(days = 1)),
) 💡 Suggestion: Rename the variable 'routineId' to 'habitId' to match the new naming convention. Example code:Existing code: val lastNotCompleted = completionHistoryRepository.getLastHistoryEntryByStatus(
routineId = habit.id!!,
matchingStatuses = listOf(HistoricalStatus.NotCompleted),
) Improved code: val lastNotCompleted = completionHistoryRepository.getLastHistoryEntryByStatus(
habitId = habit.id!!,
matchingStatuses = listOf(HistoricalStatus.NotCompleted),
) 💡 Suggestion: Rename the variable 'routineId' to 'habitId' to match the new naming convention. Example code:Existing code: streakRepository.insertStreak(
routineId = habit.id!!,
streak = Streak(
startDate = streakStart,
endDate = firstFailedStatusAfterCurrentDate
)
) Improved code: streakRepository.insertStreak(
habitId = habit.id!!,
streak = Streak(
startDate = streakStart,
endDate = firstFailedStatusAfterCurrentDate
)
) |
Type
Enhancement
Description
PR changes walkthrough
6 files
RoutineLocalDataSourceImpl.kt
core/database/src/main/java/com/rendox/routinetracker/core/database/routine/RoutineLocalDataSourceImpl.kt
Refactor routine to habit, Use HabitStatus instead of
HistoricalStatus and PlanningStatus, Add additional statuses
for clarity, Rewrite logic of habit status computation
ToggleHistoricalStatusUseCase.kt
core/domain/src/main/java/com/rendox/routinetracker/core/domain/completion_history/use_cases/ToggleHistoricalStatusUseCase.kt
Update ToggleHistoricalStatusUseCase.kt
HabitComputeStatusUseCase.kt
core/domain/src/main/java/com/rendox/routinetracker/core/domain/completion_history/HabitComputeStatusUseCase.kt
Add HabitComputeStatusUseCase.kt
Schedule.kt
core/model/src/main/java/com/rendox/routinetracker/core/model/Schedule.kt
Update Schedule.kt
InsertRoutineStatusUseCase.kt
core/domain/src/main/java/com/rendox/routinetracker/core/domain/completion_history/use_cases/InsertRoutineStatusUseCase.kt
Update InsertRoutineStatusUseCase.kt
GetRoutineStatusUseCase.kt
core/domain/src/main/java/com/rendox/routinetracker/core/domain/completion_history/use_cases/GetRoutineStatusUseCase.kt
Update GetRoutineStatusUseCase.kt
1 files
ScheduleIsDueTest.kt
core/domain/src/test/java/com/rendox/routinetracker/core/domain/routine/schedule/ScheduleIsDueTest.kt
Update ScheduleIsDueTest.kt