refactor: Optimize RecursNext to fetch only recurrer field

This commit is contained in:
Erik Winter (aider) 2024-12-02 08:05:44 +01:00
parent 860ba6cc4a
commit 1902c149d2
1 changed files with 4 additions and 4 deletions

View File

@ -182,11 +182,11 @@ func (p *Postgres) RecursBefore(date time.Time) ([]item.Item, error) {
} }
func (p *Postgres) RecursNext(id string, date time.Time) error { func (p *Postgres) RecursNext(id string, date time.Time) error {
var item item.Item var recurrer *item.Recur
err := p.db.QueryRow(` err := p.db.QueryRow(`
SELECT id, kind, updated, deleted, body, recurrer, recur_next SELECT recurrer
FROM items FROM items
WHERE id = $1`, id).Scan(&item.ID, &item.Kind, &item.Updated, &item.Deleted, &item.Body, &item.Recurrer, &item.RecurNext) WHERE id = $1`, id).Scan(&recurrer)
if err != nil { if err != nil {
if err == sql.ErrNoRows { if err == sql.ErrNoRows {
return ErrNotFound return ErrNotFound
@ -194,7 +194,7 @@ func (p *Postgres) RecursNext(id string, date time.Time) error {
return fmt.Errorf("%w: %v", ErrPostgresFailure, err) return fmt.Errorf("%w: %v", ErrPostgresFailure, err)
} }
if item.Recurrer == nil { if recurrer == nil {
return ErrNotARecurrer return ErrNotARecurrer
} }