lab6_files

This commit is contained in:
caramelteawithmint
2026-12-04 19:16:26 +03:00
parent 20afc2c790
commit 4f21a985f7
38 changed files with 2115 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
from datetime import datetime
def iso_z(dt: datetime) -> str:
"""RFC3339 UTC с 'Z'. Postgres отдаёт timestamptz с '+00:00'."""
return dt.isoformat().replace("+00:00", "Z")
def row_to_user(row) -> dict:
return {
"id": str(row["id"]),
"username": row["username"],
"display_name": row["display_name"],
"created_at": iso_z(row["created_at"]),
}
def row_to_chat(row) -> dict:
return {
"id": str(row["id"]),
"title": row["title"],
"member_ids": row["member_ids"],
"created_at": iso_z(row["created_at"]),
}
def row_to_message(row) -> dict:
return {
"id": str(row["id"]),
"chat_id": str(row["chat_id"]),
"sender_id": str(row["sender_id"]),
"text": row["text"],
"created_at": iso_z(row["created_at"]),
"attachment_ids": row.get("attachment_ids", []),
}