feat: the print file is a 300 DPI PNG, in parts of up to 15 m (item 13)
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s
All checks were successful
Build and deploy / Validate source (push) Successful in 9s
Build and deploy / Integration suite on a real stack (push) Successful in 4m55s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Successful in 1m27s
FlexiPRINT's Spot OK 1 makes the white from transparency and reads it reliably only from a PNG (Dropstar's third round, item 13): each order item is now DTF-N-item-I.png, 300 DPI, RGBA on a transparent background, with its footer; a film over 15 m leaves as DTF-N-item-I-pK.png parts, each with "Parte K/N" in its footer, cut between pieces of loose art when it can be. app/printpng.py never holds a whole sheet: the film is composed and written in bands. Pillow encodes each band (it picks the PNG filters) and one zlib stream takes them; a long PNG sheet is read band by band by wrapping its compressed rows as small PNGs; a PDF page is drawn band by band at 300 DPI by PDFium (pypdfium2, a self-contained wheel); loose art is turned and scaled once. A 57 x 220 cm sheet peaks at 191 MB, a 15 m film at 279 MB. The parts of an item are dtf_local.print_parts (print_files.upload_id stays the first); the board, the final approval, the folders and the cleanup see every part, and the Kanban approves and downloads them all. A large PNG or PDF is now generated like any other; only other large formats go to hand preparation, and the original no longer stands in as the print file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -184,7 +184,7 @@ FINAL_OK = """f.kind='final' AND f.active AND u.expires_at>now() AND u.purged_at
|
||||
# their art, nor one of their originals, nor a correction they sent. `f` is
|
||||
# the final in dtf_local.order_files, `o` its order.
|
||||
TREATED = """f.kind='final'
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.print_files p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id)
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.print_parts p WHERE p.order_id=f.order_id AND p.upload_id=f.upload_id)
|
||||
AND NOT EXISTS (SELECT 1 FROM jsonb_array_elements(o.snapshot->'items') i WHERE i->'uploads' ? f.upload_id::text)
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files k WHERE k.order_id=f.order_id AND k.upload_id=f.upload_id
|
||||
AND k.kind='correction')"""
|
||||
@@ -211,6 +211,12 @@ def with_print_files(c, orders):
|
||||
generated = c.execute('''SELECT p.order_id,p.item_index,p.status,p.upload_id,p.detail,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''', (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()
|
||||
for row in generated:
|
||||
row['parts'] = [{'upload_id': part['upload_id'], 'name': part['name']} for part in parts
|
||||
if part['order_id'] == row['order_id'] and part['item_index'] == row['item_index']]
|
||||
finals = c.execute(f'''SELECT f.order_id,f.item_index,f.upload_id FROM dtf_local.order_files f
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id WHERE f.order_id=ANY(%s) AND {FINAL_OK}''', (ids,)).fetchall()
|
||||
# Expired ones too: once corrected, a generated file is no longer the artwork.
|
||||
@@ -590,8 +596,9 @@ def delete_order(uid: UUID, user=Depends(can('manage'))):
|
||||
# order's). The worker deletes them within a minute.
|
||||
originals = {str(u) for item in row['snapshot'].get('items') or [] for u in item.get('uploads') or []}
|
||||
produced = {str(r['upload_id']) for r in c.execute('''SELECT upload_id FROM dtf_local.order_files WHERE order_id=%s
|
||||
UNION SELECT upload_id FROM dtf_local.print_files WHERE order_id=%s AND upload_id IS NOT NULL''',
|
||||
(uid, uid)).fetchall()}
|
||||
UNION SELECT upload_id FROM dtf_local.print_files WHERE order_id=%s AND upload_id IS NOT NULL
|
||||
UNION SELECT upload_id FROM dtf_local.print_parts WHERE order_id=%s''',
|
||||
(uid, uid, uid)).fetchall()}
|
||||
candidates = produced - originals if test else produced | originals
|
||||
for table in ('movements', 'order_files', 'print_files'):
|
||||
c.execute(f'DELETE FROM dtf_local.{table} WHERE order_id=%s', (uid,))
|
||||
@@ -613,12 +620,13 @@ def release_files(c, uploads):
|
||||
for upload in uploads:
|
||||
used = c.execute('''SELECT 1 FROM dtf_local.order_files WHERE upload_id=%s
|
||||
UNION ALL SELECT 1 FROM dtf_local.print_files WHERE upload_id=%s
|
||||
UNION ALL SELECT 1 FROM dtf_local.print_parts WHERE upload_id=%s
|
||||
UNION ALL SELECT 1 FROM dtf_local.orders o, jsonb_array_elements(o.snapshot->'items') i
|
||||
WHERE i->'uploads' ? %s
|
||||
UNION ALL SELECT 1 FROM dtf_local.quotes q, jsonb_array_elements(q.draft->'items') i
|
||||
WHERE q.discarded_at IS NULL AND NOT EXISTS (SELECT 1 FROM dtf_local.orders x WHERE x.quote_id=q.id)
|
||||
AND i->'uploads' ? %s
|
||||
LIMIT 1''', (upload, upload, upload, upload)).fetchone()
|
||||
LIMIT 1''', (upload,) * 5).fetchone()
|
||||
if not used:
|
||||
free.append(upload)
|
||||
if free:
|
||||
@@ -1360,17 +1368,19 @@ def print_ready(c, states, only=None, paid_after=None):
|
||||
WHERE o.state=ANY(%s) AND (%s::uuid[] IS NULL OR o.id=ANY(%s))
|
||||
AND (%s::timestamptz IS NULL OR o.created_at>=%s) AND o.cancelled_at IS NULL AND {FINAL_OK}
|
||||
UNION ALL
|
||||
SELECT o.id,o.state,o.number,p.item_index,p.upload_id,u.object_key,u.name,
|
||||
SELECT o.id,o.state,o.number,p.item_index,pp.upload_id,u.object_key,u.name,
|
||||
COALESCE(o.queue_key, extract(epoch FROM o.created_at))
|
||||
FROM dtf_local.orders o
|
||||
JOIN dtf_local.print_files p ON p.order_id=o.id JOIN dtf_local.uploads u ON u.id=p.upload_id
|
||||
JOIN dtf_local.print_files p ON p.order_id=o.id
|
||||
JOIN dtf_local.print_parts pp ON pp.order_id=p.order_id AND pp.item_index=p.item_index
|
||||
JOIN dtf_local.uploads u ON u.id=pp.upload_id
|
||||
WHERE o.state=ANY(%s) AND (%s::uuid[] IS NULL OR o.id=ANY(%s))
|
||||
AND (%s::timestamptz IS NULL OR o.created_at>=%s) AND o.state IN ('rec','tra') AND o.cancelled_at IS NULL AND p.status='ready'
|
||||
AND u.expires_at>now() AND u.purged_at IS NULL AND u.scan_state='clean'
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=o.id AND f.kind='final'
|
||||
AND f.active AND f.item_index=p.item_index)
|
||||
AND NOT EXISTS (SELECT 1 FROM dtf_local.order_files f WHERE f.order_id=o.id AND f.kind='correction')
|
||||
ORDER BY position,order_id,item_index''',
|
||||
ORDER BY position,order_id,item_index,name''',
|
||||
(list(states), ids, ids, paid_after, paid_after, list(states), ids, ids, paid_after, paid_after)).fetchall()
|
||||
return rows
|
||||
|
||||
|
||||
Reference in New Issue
Block a user