fix(database): fix filter regression from clean-up (#599)

* fix(database): fix filter regression from clean-up

* rollback transaction commits

* fix(database): revert action count query
This commit is contained in:
Kyle Sanderson 2022-12-31 03:27:42 -08:00 committed by GitHub
parent 6b1490726f
commit 5da28a0918
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 19 deletions

View file

@ -28,7 +28,6 @@ func NewActionRepo(log logger.Logger, db *DB, clientRepo domain.DownloadClientRe
} }
func (r *ActionRepo) FindByFilterID(ctx context.Context, filterID int) ([]*domain.Action, error) { func (r *ActionRepo) FindByFilterID(ctx context.Context, filterID int) ([]*domain.Action, error) {
tx, err := r.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted}) tx, err := r.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted})
if err != nil { if err != nil {
return nil, err return nil, err
@ -51,10 +50,6 @@ func (r *ActionRepo) FindByFilterID(ctx context.Context, filterID int) ([]*domai
} }
} }
if err = tx.Commit(); err != nil {
return nil, errors.Wrap(err, "error finding filter by id")
}
return actions, nil return actions, nil
} }
@ -611,8 +606,7 @@ func (r *ActionRepo) StoreFilterActions(ctx context.Context, actions []*domain.A
r.log.Debug().Msgf("action.StoreFilterActions: store '%v' type: '%v' on filter: %v", action.Name, action.Type, filterID) r.log.Debug().Msgf("action.StoreFilterActions: store '%v' type: '%v' on filter: %v", action.Name, action.Type, filterID)
} }
err = tx.Commit() if err := tx.Commit(); err != nil {
if err != nil {
return nil, errors.Wrap(err, "error updating filter actions") return nil, errors.Wrap(err, "error updating filter actions")
} }

View file

@ -52,7 +52,7 @@ func (r *FilterRepo) find(ctx context.Context, tx *Tx, params domain.FilterQuery
actionCountQuery := r.db.squirrel. actionCountQuery := r.db.squirrel.
Select("COUNT(*)"). Select("COUNT(*)").
From("action a"). From("action a").
Where(sq.Eq{"a.filter_id": "f.id"}) Where("a.filter_id = f.id")
queryBuilder := r.db.squirrel. queryBuilder := r.db.squirrel.
Select( Select(
@ -123,7 +123,7 @@ func (r *FilterRepo) ListFilters(ctx context.Context) ([]domain.Filter, error) {
actionCountQuery := r.db.squirrel. actionCountQuery := r.db.squirrel.
Select("COUNT(*)"). Select("COUNT(*)").
From("action a"). From("action a").
Where(sq.Eq{"a.filter_id": "f.id"}) Where("a.filter_id = f.id")
queryBuilder := r.db.squirrel. queryBuilder := r.db.squirrel.
Select( Select(

View file

@ -109,10 +109,6 @@ func (repo *ReleaseRepo) Find(ctx context.Context, params domain.ReleaseQueryPar
return nil, nextCursor, total, err return nil, nextCursor, total, err
} }
if err = tx.Commit(); err != nil {
return nil, 0, 0, errors.Wrap(err, "error commit transaction find releases")
}
return releases, nextCursor, total, nil return releases, nextCursor, total, nil
} }
@ -313,10 +309,6 @@ func (repo *ReleaseRepo) FindRecent(ctx context.Context) ([]*domain.Release, err
return nil, err return nil, err
} }
if err = tx.Commit(); err != nil {
return nil, errors.Wrap(err, "error transaction commit")
}
return releases, nil return releases, nil
} }
@ -487,8 +479,7 @@ func (repo *ReleaseRepo) Delete(ctx context.Context) error {
return errors.Wrap(err, "error executing query") return errors.Wrap(err, "error executing query")
} }
err = tx.Commit() if err := tx.Commit(); err != nil {
if err != nil {
return errors.Wrap(err, "error commit transaction delete") return errors.Wrap(err, "error commit transaction delete")
} }