fixes
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-23 18:28:52 +03:00
parent 396d149849
commit 3d33f0807f
5 changed files with 57 additions and 11 deletions
+6 -7
View File
@@ -35,17 +35,16 @@ def snapshot(service, compose, database):
raw = subprocess.check_output(
compose + [
'exec', '-T', service, 'psql', '-U', 'messenger', '-d', database, '-tAc',
"SELECT id::text || '|' || chat_id::text || '|' || text FROM messages "
'ORDER BY created_at DESC, id DESC LIMIT 5',
"SELECT COALESCE(json_agg(json_build_object("
"'id', id::text, 'chat_id', chat_id::text, 'text', text) "
"ORDER BY created_at DESC, id DESC), '[]'::json)::text "
'FROM (SELECT id, chat_id, text, created_at FROM messages '
'ORDER BY created_at DESC, id DESC LIMIT 5) AS sample',
],
cwd=ROOT,
text=True,
).strip()
sample = []
if raw:
for line in raw.splitlines():
parts = line.split('|', 2)
sample.append({'id': parts[0], 'chat_id': parts[1], 'text': parts[2]})
sample = json.loads(raw)
return {'messages': messages, 'users': users, 'sample': sample}