Fix consumed instruction ordering and clear history
This commit is contained in:
@@ -135,9 +135,10 @@ func (s *InstructionStore) Create(content string) (*models.Instruction, error) {
|
||||
id := uuid.New().String()
|
||||
now := time.Now().UTC()
|
||||
|
||||
// Assign next position
|
||||
// Assign next position from the full instruction history so positions remain
|
||||
// globally stable even after the pending queue empties.
|
||||
var maxPos sql.NullInt64
|
||||
_ = s.db.QueryRow(`SELECT MAX(position) FROM instructions WHERE status = 'pending'`).Scan(&maxPos)
|
||||
_ = s.db.QueryRow(`SELECT MAX(position) FROM instructions`).Scan(&maxPos)
|
||||
position := int(maxPos.Int64) + 1
|
||||
|
||||
_, err := s.db.Exec(`
|
||||
|
||||
Reference in New Issue
Block a user