feat: Kanban columns are queues, and a card can be dragged up or down
Some checks failed
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Failing after 3m24s
Build and deploy / Secret scan and release gate (push) Successful in 8s
Build and deploy / Publish images (push) Has been skipped

Each column is sorted explicitly by payment time, first paid on top, however
the board's list was put together (older finished orders, one opened from the
search). A card dragged within its column lands between the two it was
dropped between (queue_key, halfway between their keys) and keeps that place
for everyone; moving to another stage clears it. Reordering is not activity:
the stalled clock keeps running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-02 16:57:31 -03:00
parent d7b1eaae6d
commit 894e75fd94
5 changed files with 114 additions and 12 deletions

View File

@@ -18,10 +18,11 @@ def run():
mail = f'actions-{uuid4().hex[:8]}@example.test'
approved = {'customer': {'mail': mail}, 'items': [], 'total_cents': 1490}
discard, test_quote, paid_quote, paid_order = uuid4(), uuid4(), uuid4(), uuid4()
newer_quote, newer_order = uuid4(), uuid4()
test_order = None
try:
with db.connect() as c:
for qid in (discard, test_quote, paid_quote):
for qid in (discard, test_quote, paid_quote, newer_quote):
c.execute('''INSERT INTO dtf_local.quotes(id,owner,request_key,request_hash,draft,approved,approved_at)
VALUES(%s,%s,%s,'actions-fixture',%s,%s,now())''',
(qid, owner, uuid4(), Jsonb({'customer': {'mail': mail}, 'items': []}), Jsonb(approved)))
@@ -63,6 +64,20 @@ def run():
operator=True, expected=409)
client.call(f'/operator/orders/{paid_order}/cancel', {'note': 'de novo'}, operator=True, expected=404)
# Dragged within its column: first paid first, unless moved; moving on resets it.
with db.connect() as c:
c.execute("UPDATE dtf_local.orders SET created_at=now()-interval '1 hour' WHERE id=%s", (paid_order,))
c.execute('''INSERT INTO dtf_local.orders(id,quote_id,owner,snapshot,payment,created_at)
VALUES(%s,%s,%s,%s,%s,now())''', (newer_order, newer_quote, owner, Jsonb(approved),
Jsonb({'provider': 'teste', 'id': 't'})))
client.call(f'/operator/orders/{newer_order}/queue', {'before': str(paid_order)}, operator=True)
with db.connect() as c:
keys = {str(r['id']): r['k'] for r in c.execute(
'SELECT id, COALESCE(queue_key, extract(epoch FROM created_at)) AS k FROM dtf_local.orders WHERE id=ANY(%s)',
([paid_order, newer_order],)).fetchall()}
assert keys[str(newer_order)] < keys[str(paid_order)], keys
client.call(f'/operator/orders/{newer_order}/queue', {}, operator=True, expected=422)
# Cancelled, it can be deleted; its quote is discarded, not unpaid again.
client.call(f'/operator/orders/{paid_order}/delete', {}, operator=True)
with db.connect() as c:
@@ -72,13 +87,13 @@ def run():
print('PASS: discard hides and blocks a quote; test orders delete; paid orders cancel, then delete')
finally:
with db.connect() as c:
for oid in filter(None, (test_order, paid_order)):
for oid in filter(None, (test_order, paid_order, newer_order)):
for table in ('movements', 'order_files', 'print_files'):
c.execute(f'DELETE FROM dtf_local.{table} WHERE order_id=%s', (oid,))
c.execute('DELETE FROM dtf_local.outbox WHERE event_key LIKE %s', (f'{oid}:%',))
c.execute('DELETE FROM dtf_local.orders WHERE id=%s', (oid,))
c.execute('DELETE FROM dtf_local.orders WHERE quote_id=ANY(%s)', ([discard, test_quote, paid_quote],))
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', ([discard, test_quote, paid_quote],))
c.execute('DELETE FROM dtf_local.orders WHERE quote_id=ANY(%s)', ([discard, test_quote, paid_quote, newer_quote],))
c.execute('DELETE FROM dtf_local.quotes WHERE id=ANY(%s)', ([discard, test_quote, paid_quote, newer_quote],))
if __name__ == '__main__':