Feature/calendar #69
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!69
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/calendar"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +99,4 @@func lastActiveWeek(grid [][]int) int {for i := len(grid) - 1; i >= 0; i-- {for _, day := range grid[i] {if day > 0 {DRY violation: This exact calculation
time.Date(newYear, newMonth+1, 0, 0, 0, 0, 0, time.Local).Day()is duplicated inPrevMonth()at line 130. Extract this into a helper function:Then both functions can use:
lastDayOfNewMonth := getLastDayOfMonth(newYear, newMonth)@ -0,0 +103,4 @@return i}}}DRY violation: This clamping logic (lines 102-106) is duplicated in
PrevMonth()(lines 130-134). After extracting thegetLastDayOfMonthhelper, extract the clamping logic:PR Summary (auto-generated)
due_datetimestamp column to the tasks table across both SQLite and PostgreSQL@ -907,0 +975,4 @@m.Pickers.DatePicker.CurrentYear,m.Pickers.DatePicker.CurrentMonth,m.Pickers.DatePicker.CursorDay,0, 0, 0, 0,DRY violation: This entire block (clearing due date and updating database) is duplicated at lines 986-1001 (setting due date). The only difference is the date value and notification message. Extract to a helper:
Then call:
m.updateDueDateIfEditing(nil, "Due date cleared")andm.updateDueDateIfEditing(&selectedDate, "Due date set to "+selectedDate.Format("Jan 2, 2006"))@ -907,0 +975,4 @@m.Pickers.DatePicker.CurrentYear,m.Pickers.DatePicker.CurrentMonth,m.Pickers.DatePicker.CursorDay,0, 0, 0, 0,DRY violation: This block (clearing due date + database update) is duplicated at lines 986-1004. Extract to a helper method:
DRY violation: This null time conversion pattern is duplicated in the new
UpdateTaskDueDatemethod. Add a helper tointernal/database/types/nullable.go:Then use:
dueDate := types.NullTimeFromPointer(req.DueDate)@ -0,0 +109,4 @@s.CurrentMonth = newMonths.CursorDay = newDay// Do NOT update cursorWant - keep the desired position for future navigation}DRY violation:
NextMonth()andPrevMonth()(lines 114-140) contain duplicated logic. Both functions:time.Date(newYear, newMonth+1, 0, ...)Refactor to eliminate duplication:
Then
NextMonth()becomess.changeMonth(1)andPrevMonth()becomess.changeMonth(-1).@ -61,1 +61,4 @@}if t.DueDate.Valid {task.DueDate = &t.DueDate.Time}Minor improvement: This null-to-pointer conversion pattern is used 4 times in this file (lines 53-64). Consider extracting to a helper in the types package:
Then:
task.DueDate = t.DueDate.ToPointer()Same for
NullStringandNullInt64.Code Review Summary
This PR adds due date functionality to tasks. The implementation is functional but contains several refactoring opportunities to reduce code duplication.
Key Issues Found
1. DRY Violations - Date Picker State (High Priority)
NextMonth()andPrevMonth()indate_picker_state.gocontain nearly identical logic (22 lines duplicated)2. DRY Violations - Renderer Helpers (Medium Priority)
date_picker.goduplicates last-day-of-month calculation in two places3. DRY Violations - Update Handlers (Medium Priority)
update_pickers.goduplicates the "update database if editing" pattern for clearing/setting due dates4. Missing Helper Methods (Low Priority)
types.NullTime → *time.Time) lack utility methodsNullTime{Time: *ptr, Valid: true}Test Coverage
Security & Performance
Recommendation
Approve with suggestions for follow-up refactoring. The functionality works correctly and is well-tested. The DRY violations should be addressed in a follow-up PR to improve maintainability, but they don't block this feature.