mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
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:
parent
6b1490726f
commit
5da28a0918
3 changed files with 4 additions and 19 deletions
|
@ -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) {
|
||||
|
||||
tx, err := r.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelReadCommitted})
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
if err := tx.Commit(); err != nil {
|
||||
return nil, errors.Wrap(err, "error updating filter actions")
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func (r *FilterRepo) find(ctx context.Context, tx *Tx, params domain.FilterQuery
|
|||
actionCountQuery := r.db.squirrel.
|
||||
Select("COUNT(*)").
|
||||
From("action a").
|
||||
Where(sq.Eq{"a.filter_id": "f.id"})
|
||||
Where("a.filter_id = f.id")
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
Select(
|
||||
|
@ -123,7 +123,7 @@ func (r *FilterRepo) ListFilters(ctx context.Context) ([]domain.Filter, error) {
|
|||
actionCountQuery := r.db.squirrel.
|
||||
Select("COUNT(*)").
|
||||
From("action a").
|
||||
Where(sq.Eq{"a.filter_id": "f.id"})
|
||||
Where("a.filter_id = f.id")
|
||||
|
||||
queryBuilder := r.db.squirrel.
|
||||
Select(
|
||||
|
|
|
@ -109,10 +109,6 @@ func (repo *ReleaseRepo) Find(ctx context.Context, params domain.ReleaseQueryPar
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -313,10 +309,6 @@ func (repo *ReleaseRepo) FindRecent(ctx context.Context) ([]*domain.Release, err
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err = tx.Commit(); err != nil {
|
||||
return nil, errors.Wrap(err, "error transaction commit")
|
||||
}
|
||||
|
||||
return releases, nil
|
||||
}
|
||||
|
||||
|
@ -487,8 +479,7 @@ func (repo *ReleaseRepo) Delete(ctx context.Context) error {
|
|||
return errors.Wrap(err, "error executing query")
|
||||
}
|
||||
|
||||
err = tx.Commit()
|
||||
if err != nil {
|
||||
if err := tx.Commit(); err != nil {
|
||||
return errors.Wrap(err, "error commit transaction delete")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue