Refactor habit entries: remove soft delete and add smart pagination
Remove soft delete from HabitEntry: - Eliminate DeletedAt field from entity and database - Change UnmarkHabit from soft delete to hard delete - Simplify all queries removing deleted_at checks - Update migration to remove deleted_at column Add date filtering and smart pagination to GetHabitEntries: - Support optional from/to date parameters - Implement intelligent pagination rules: * No date range: pagination required * Date range > 1 year: pagination required * Date range ≤ 1 year: pagination optional - Pagination defaults (page=1, limit=50) only when required - Return metadata with total count, page, and limit Technical improvements: - Cleaner codebase without soft delete complexity - Better performance (no filtering in queries) - More intuitive API with flexible pagination - Comprehensive test coverage for validation rules
This commit is contained in:
@@ -8,7 +8,6 @@ type HabitEntry struct {
|
||||
ScheduledDate time.Time
|
||||
CompletedAt time.Time
|
||||
Value *float64
|
||||
DeletedAt *time.Time
|
||||
}
|
||||
|
||||
func NewHabitEntry(habitID string, scheduledDate time.Time, value *float64) *HabitEntry {
|
||||
@@ -19,12 +18,3 @@ func NewHabitEntry(habitID string, scheduledDate time.Time, value *float64) *Hab
|
||||
Value: value,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *HabitEntry) Delete() {
|
||||
now := time.Now()
|
||||
e.DeletedAt = &now
|
||||
}
|
||||
|
||||
func (e *HabitEntry) IsDeleted() bool {
|
||||
return e.DeletedAt != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user