All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s
Combines shared, blog, market, cart, events, federation, and account into a single repository. Eliminates submodule sync, sibling model copying at build time, and per-app CI orchestration. Changes: - Remove per-app .git, .gitmodules, .gitea, submodule shared/ dirs - Remove stale sibling model copies from each app - Update all 6 Dockerfiles for monorepo build context (root = .) - Add build directives to docker-compose.yml - Add single .gitea/workflows/ci.yml with change detection - Add .dockerignore for monorepo build context - Create __init__.py for federation and account (cross-app imports)
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""Group individual TicketDTOs by (entry_id, ticket_type_id) for cart display."""
|
|
from __future__ import annotations
|
|
|
|
from collections import OrderedDict
|
|
|
|
|
|
def group_tickets(tickets) -> list[dict]:
|
|
"""
|
|
Group a flat list of TicketDTOs into aggregate rows.
|
|
|
|
Returns list of dicts:
|
|
{
|
|
"entry_id": int,
|
|
"entry_name": str,
|
|
"entry_start_at": datetime,
|
|
"entry_end_at": datetime | None,
|
|
"ticket_type_id": int | None,
|
|
"ticket_type_name": str | None,
|
|
"price": Decimal | None,
|
|
"quantity": int,
|
|
"line_total": float,
|
|
}
|
|
"""
|
|
groups: OrderedDict[tuple, dict] = OrderedDict()
|
|
|
|
for tk in tickets:
|
|
key = (tk.entry_id, getattr(tk, "ticket_type_id", None))
|
|
if key not in groups:
|
|
groups[key] = {
|
|
"entry_id": tk.entry_id,
|
|
"entry_name": tk.entry_name,
|
|
"entry_start_at": tk.entry_start_at,
|
|
"entry_end_at": tk.entry_end_at,
|
|
"ticket_type_id": getattr(tk, "ticket_type_id", None),
|
|
"ticket_type_name": tk.ticket_type_name,
|
|
"price": tk.price,
|
|
"quantity": 0,
|
|
"line_total": 0,
|
|
}
|
|
groups[key]["quantity"] += 1
|
|
groups[key]["line_total"] += float(tk.price or 0)
|
|
|
|
return list(groups.values())
|