This commit is contained in:
@@ -221,6 +221,31 @@ func (s *Store) listOrders(status string, limit int, archived bool) ([]Order, er
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) ListOrdersWithDeletableThreads(cutoff time.Time, limit int) ([]Order, error) {
|
||||
if limit <= 0 || limit > 100 {
|
||||
limit = 50
|
||||
}
|
||||
rows, err := s.db.Query(`SELECT id, submitter_id, submitter_name, acceptor_id, acceptor_name, commodity, quality, quantity_amount, quantity_unit, deadline, delivery_place, max_budget_auec, status, public_channel_id, public_message_id, internal_channel_id, internal_message_id, thread_id, created_at, updated_at, last_feedback FROM orders WHERE thread_id <> '' AND status IN (?, ?, ?) AND updated_at <= ? ORDER BY updated_at ASC LIMIT ?`, StatusCompleted, StatusDeclined, StatusCancelled, cutoff.UTC(), limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var out []Order
|
||||
for rows.Next() {
|
||||
o, err := scanOrder(rows)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, *o)
|
||||
}
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func (s *Store) ClearThreadID(orderID int64) error {
|
||||
_, err := s.db.Exec(`UPDATE orders SET thread_id='', updated_at=? WHERE id=?`, time.Now().UTC(), orderID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Store) AcceptOrder(id int64, userID, userName string) (*Order, error) {
|
||||
tx, err := s.db.Begin()
|
||||
if err != nil {
|
||||
@@ -281,7 +306,7 @@ func (s *Store) SetStatus(id int64, status, feedback, actorID, actorName string)
|
||||
if n == 0 {
|
||||
return nil, sql.ErrNoRows
|
||||
}
|
||||
if err := addEventTx(tx, id, actorID, actorName, EventOrderStatus, fmt.Sprintf("Status auf %s gesetzt: %s", status, feedback)); err != nil {
|
||||
if err := addEventTx(tx, id, actorID, actorName, EventOrderStatus, fmt.Sprintf("Status auf %s gesetzt: %s", statusLabel(status), feedback)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := tx.Commit(); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user