refactor: Optimize RecursNext to fetch only recurrer field
This commit is contained in:
parent
860ba6cc4a
commit
1902c149d2
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue