feat: Prumo tells the card and the customer what it did (front 6)
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 4m41s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m6s
All checks were successful
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 4m41s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m6s
Every order now carries a short report of the decisions that happened: original format, conversion, resolution, background, residue, montage, billed length, contraction, thin-stroke warning, parts and generation time. The card shows it above the file; the payment summary shows the customer's version. The upload keeps the original name so a renamed CDR/PDF is told.
This commit is contained in:
@@ -18,7 +18,7 @@ from ..core.auth import (COOKIE_SECURE, DUMMY_PASSWORD_HASH, MOVERS, audit, can,
|
||||
login_failed, may_move, may_reorder, password_matches, throttle)
|
||||
from ..core.models import Contraction, Move, OperatorLogin, Resolution, Review, StrictModel, UploadStart
|
||||
from ..printjobs import CLAIM_TIMEOUT, file_prefix, queue as queue_print_files
|
||||
from .. import cnpj, hotfolder, machines, mail, payments, proof, quote_review, receipt
|
||||
from .. import cnpj, hotfolder, machines, mail, payments, proof, prumo, quote_review, receipt
|
||||
from .. import tiny
|
||||
from ..runtime import (BACK, BOARD_FINISHED_LIMIT, BOARD_QUOTE_LIMIT, ENVIRONMENT, PUBLIC_ORIGIN, STATES,
|
||||
TRANSITIONS, payment, enqueue, freight, operator_identity, quote_view, quote_views, storage, upload_row)
|
||||
@@ -215,10 +215,16 @@ def with_print_files(c, orders):
|
||||
approved, and the customer's corrections waiting to be approved as finals."""
|
||||
ids = [o['id'] for o in orders]
|
||||
generated = c.execute('''SELECT p.order_id,p.item_index,p.status,p.upload_id,p.detail,p.claimed_at,p.finished_at,
|
||||
p.created_at,
|
||||
(p.status='rendering' AND p.claimed_at<now()-%s) AS timed_out,
|
||||
p.claimed_at+%s AS timeout_at,u.name
|
||||
FROM dtf_local.print_files p LEFT JOIN dtf_local.uploads u ON u.id=p.upload_id
|
||||
WHERE p.order_id=ANY(%s) ORDER BY p.item_index''', (CLAIM_TIMEOUT, CLAIM_TIMEOUT, ids)).fetchall()
|
||||
upload_ids = sorted({str(uid) for order in orders for item in order['snapshot']['items']
|
||||
for uid in item.get('uploads') or []})
|
||||
uploads = {row['id']: row for row in c.execute(
|
||||
'''SELECT id::text AS id,name,original_name FROM dtf_local.uploads WHERE id::text=ANY(%s)''',
|
||||
(upload_ids,)).fetchall()}
|
||||
# A film over 15 m is several PNGs, in order (item 13).
|
||||
parts = c.execute('''SELECT p.order_id,p.item_index,p.part,p.upload_id,u.name FROM dtf_local.print_parts p
|
||||
JOIN dtf_local.uploads u ON u.id=p.upload_id WHERE p.order_id=ANY(%s) ORDER BY p.part''', (ids,)).fetchall()
|
||||
@@ -261,6 +267,7 @@ def with_print_files(c, orders):
|
||||
order['proof_parent'] = parent and {'id': parent['id'], 'number': parent['number'], 'state': parent['state']}
|
||||
order['correction_reason'] = reasons.get(order['id']) if order['state'] == 'cor' else None
|
||||
order['print_files'] = [row for row in generated if row['order_id'] == order['id']]
|
||||
order['prumo'] = prumo.report(order, uploads)
|
||||
approved = [row for row in finals if row['order_id'] == order['id']]
|
||||
order['final_items'] = sorted({row['item_index'] for row in approved})
|
||||
# The approved finals themselves: "Tratar a arte" keeps those it does not replace.
|
||||
|
||||
@@ -14,7 +14,7 @@ from ..core.auth import owner
|
||||
from ..core.models import QuoteRequest
|
||||
from ..core.pricing import price
|
||||
from .. import quote_review
|
||||
from ..grade_check import Files, mismatch, resolution_issue
|
||||
from ..grade_check import Files, mismatch, resolution_issue, source_dpi
|
||||
from ..runtime import freight, payment, quote_view, require_delivery_available, storage, upload_row
|
||||
from ..scanning import require_clean
|
||||
|
||||
@@ -59,6 +59,16 @@ def create_quote(body: QuoteRequest, session_id=Depends(owner)):
|
||||
# longer sets the price): before a cart is approved at checkout, the
|
||||
# server works it out from the files.
|
||||
files = Files(storage)
|
||||
# Record the lowest source resolution for the Prumo report (front 6).
|
||||
for draft_item, item in zip(draft['items'], body.items):
|
||||
dpis = []
|
||||
for source in item.production.sources:
|
||||
row = rows.get(str(source.upload_id))
|
||||
dpi = source_dpi(files, row, source.model_dump(mode='json')) if row else None
|
||||
if dpi:
|
||||
dpis.append(dpi)
|
||||
if dpis:
|
||||
draft_item['source_dpi'] = round(min(dpis))
|
||||
issue = resolution_issue(files, draft['items'], rows)
|
||||
if issue:
|
||||
raise HTTPException(422, issue)
|
||||
|
||||
@@ -41,9 +41,9 @@ def begin_upload(body: UploadStart, session_id=Depends(owner)):
|
||||
audit('upload_quota_rejected')
|
||||
raise HTTPException(429, 'Limite de armazenamento ou de envios pendentes atingido. Tente de novo mais tarde.')
|
||||
multipart = storage.begin(key)
|
||||
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,size,object_key,multipart_id,expires_at)
|
||||
VALUES(%s,%s,%s,%s,%s,%s,now()+interval '1 hour')''',
|
||||
(uid, session_id, body.name, body.size, key, multipart))
|
||||
c.execute('''INSERT INTO dtf_local.uploads(id,owner,name,original_name,size,object_key,multipart_id,expires_at)
|
||||
VALUES(%s,%s,%s,%s,%s,%s,%s,now()+interval '1 hour')''',
|
||||
(uid, session_id, body.name, body.name, body.size, key, multipart))
|
||||
return {'id': uid, 'part_bytes': PART_BYTES}
|
||||
|
||||
@router.get('/api/uploads/{uid}')
|
||||
|
||||
Reference in New Issue
Block a user