refactor: deduplicate engine internals, replace bubble sorts, remove dead code
Extract shared code that was duplicated across functions: - taskJSON struct (MarshalJSON/UnmarshalJSON) to package-level type - scanTask(scanner) helper for GetTask/GetTasks (~70 identical lines) - monthNames map for parseMonthName/parseDayAndMonth - applyNonDateAttribute helper for Apply/ApplyToNew - resolveDisplayID calls replace inline loops in FormatTaskListWithFormat Replace O(n²) bubble sorts with sort.Slice in all four report sort functions (sortByUrgency, NewestReport, NextReport, OldestReport). Remove dead code: formatTimeWithColor (unused, also used time.Now() instead of timeNow()), getCurrentTimestamp (unnecessary wrapper). Remove ~20 comments that restated the next line of code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -334,7 +334,7 @@ func runMigrations() error {
|
||||
if _, err := tx.Exec(
|
||||
"INSERT INTO schema_version (version, applied_at) VALUES (?, ?)",
|
||||
migration.version,
|
||||
getCurrentTimestamp(),
|
||||
GetCurrentTimestamp(),
|
||||
); err != nil {
|
||||
tx.Rollback()
|
||||
return fmt.Errorf("failed to record migration %d: %w", migration.version, err)
|
||||
@@ -349,14 +349,9 @@ func runMigrations() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// getCurrentTimestamp returns the current Unix timestamp
|
||||
func getCurrentTimestamp() int64 {
|
||||
return timeNow().Unix()
|
||||
}
|
||||
|
||||
// GetCurrentTimestamp returns the current Unix timestamp (exported for API use)
|
||||
func GetCurrentTimestamp() int64 {
|
||||
return getCurrentTimestamp()
|
||||
return timeNow().Unix()
|
||||
}
|
||||
|
||||
// CleanupChangeLog removes old change log entries based on retention policy
|
||||
|
||||
Reference in New Issue
Block a user