Skip to content
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

cleanup duplicate code for list records function #164

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions core/record.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,7 @@ func (t *Timetrace) LoadBackupRecord(start time.Time) (*Record, error) {
// ListRecords loads and returns all records from the given date. If no records
// are found, an empty slice and no error will be returned.
func (t *Timetrace) ListRecords(date time.Time) ([]*Record, error) {
dir := t.fs.RecordDirFromDate(date)
paths, err := t.fs.RecordFilepaths(dir, func(_, _ string) bool {
return true
})
if err != nil {
return nil, err
}

records := make([]*Record, 0)

for _, path := range paths {
record, err := t.loadRecord(path)
if err != nil {
return nil, err
}
records = append(records, record)
}

return records, nil
return t.loadAllRecords(date)
}

// SaveRecord persists the given record. Returns ErrRecordAlreadyExists if the
Expand Down