From 1902c149d28400d92049e2c79f8387c0cfd2ff6b Mon Sep 17 00:00:00 2001 From: "Erik Winter (aider)" Date: Mon, 2 Dec 2024 08:05:44 +0100 Subject: [PATCH] refactor: Optimize RecursNext to fetch only recurrer field --- sync/service/postgres.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sync/service/postgres.go b/sync/service/postgres.go index 1a7cf95..84dbd49 100644 --- a/sync/service/postgres.go +++ b/sync/service/postgres.go @@ -182,11 +182,11 @@ func (p *Postgres) RecursBefore(date time.Time) ([]item.Item, error) { } func (p *Postgres) RecursNext(id string, date time.Time) error { - var item item.Item + var recurrer *item.Recur err := p.db.QueryRow(` - SELECT id, kind, updated, deleted, body, recurrer, recur_next + SELECT recurrer 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 == sql.ErrNoRows { return ErrNotFound @@ -194,7 +194,7 @@ func (p *Postgres) RecursNext(id string, date time.Time) error { return fmt.Errorf("%w: %v", ErrPostgresFailure, err) } - if item.Recurrer == nil { + if recurrer == nil { return ErrNotARecurrer }