added batch limits

This commit is contained in:
Cam Otts
2023-01-12 14:09:04 -06:00
parent 0db3f0c9e6
commit 679aa09615
4 changed files with 29 additions and 20 deletions

View File

@@ -44,8 +44,8 @@ func (self *Store) FindAccountRequestWithToken(token string, tx *sqlx.Tx) (*Acco
return ar, nil
}
func (self *Store) FindExpiredAccountRequests(before time.Time, tx *sqlx.Tx) ([]*AccountRequest, error) {
rows, err := tx.Queryx("select * from account_requests where created_at < $1", before)
func (self *Store) FindExpiredAccountRequests(before time.Time, limit int, tx *sqlx.Tx) ([]*AccountRequest, error) {
rows, err := tx.Queryx(fmt.Sprintf("select * from account_requests where created_at < $1 limit %d for update", limit), before)
if err != nil {
return nil, errors.Wrap(err, "error selecting expired account_requests")
}