feat: every order is born with its origin, shown, filtered and counted (Dropstar's rules D-21 and D-35)
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m21s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m1s
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 3m21s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 1m1s
Orders carry site, dropflow or atendimento, required and with no default, limited to the three. The Site's orders are marked site where they are created; older orders became site. The Kanban shows the origin on each card and in the order panel, filters by it, and Numeros has a Por origem table: orders, metres, money and time from payment to Finalizado per way in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from urllib.request import Request
|
||||
from uuid import uuid4
|
||||
|
||||
import httpx
|
||||
import psycopg
|
||||
from psycopg.types.json import Jsonb
|
||||
|
||||
from app.core import db
|
||||
@@ -81,8 +82,8 @@ def run():
|
||||
c.execute('''INSERT INTO dtf_local.quotes(id,owner,request_key,request_hash,draft,approved)
|
||||
VALUES(%s,%s,%s,%s,%s,%s)''', (qid, owner, uuid4(), 'kanban-fixture', Jsonb(content),
|
||||
Jsonb(accepted) if accepted else None))
|
||||
number = c.execute('''INSERT INTO dtf_local.orders(id,quote_id,owner,snapshot,payment)
|
||||
VALUES(%s,%s,%s,%s,%s) RETURNING number''',
|
||||
number = c.execute('''INSERT INTO dtf_local.orders(id,quote_id,owner,snapshot,payment,origin)
|
||||
VALUES(%s,%s,%s,%s,%s,'site') RETURNING number''',
|
||||
(order_id, paid, owner, Jsonb({**draft(item('file')), 'total_cents': 1490}),
|
||||
Jsonb({'provider': 'teste', 'id': f'kanban-{tag}'}))).fetchone()['number']
|
||||
|
||||
@@ -126,6 +127,20 @@ def run():
|
||||
assert (after['orders'], after['cents']) == (before['orders'] + 1, before['cents'] + 1490), (before, after)
|
||||
assert after['daily'][-1]['orders'] == before['daily'][-1]['orders'] + 1
|
||||
assert after['waiting']['rec']['orders'] == before.get('waiting', {}).get('rec', {}).get('orders', 0) + 1
|
||||
# Each way in apart (D-21), all three listed even when empty.
|
||||
assert [o['origin'] for o in after['origins']] == ['site', 'dropflow', 'atendimento']
|
||||
site = lambda stats: next(o for o in stats['origins'] if o['origin'] == 'site')
|
||||
assert (site(after)['orders'], site(after)['cents']) == (site(before)['orders'] + 1, site(before)['cents'] + 1490)
|
||||
# No order without an origin, and only the three (D-21, D-35).
|
||||
for origin in (None, 'whatsapp'):
|
||||
try:
|
||||
with db.connect() as c:
|
||||
c.execute('''INSERT INTO dtf_local.orders(id,quote_id,owner,snapshot,payment,origin)
|
||||
VALUES(%s,%s,%s,'{}','{}',%s)''', (uuid4(), approved, owner, origin))
|
||||
except (psycopg.errors.NotNullViolation, psycopg.errors.CheckViolation):
|
||||
pass
|
||||
else:
|
||||
raise AssertionError(f'an order with origin {origin!r} was accepted')
|
||||
client.call('/operator/stats?days=3', operator=True, expected=422)
|
||||
# Or two dates: the same week asked as a range gives the same numbers.
|
||||
week = client.call(f"/operator/stats?start={after['start']}&end={after['end']}", operator=True)
|
||||
|
||||
Reference in New Issue
Block a user