All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 3m0s
Replace every direct cross-app services.* call with HTTP-based communication: call_action() for writes, fetch_data() for reads. Each app now registers only its own domain service. Infrastructure: - shared/infrastructure/actions.py — POST client for /internal/actions/ - shared/infrastructure/data_client.py — GET client for /internal/data/ - shared/contracts/dtos.py — dto_to_dict/dto_from_dict serialization Action endpoints (writes): - events: 8 handlers (ticket adjust, claim/confirm, toggle, adopt) - market: 2 handlers (create/soft-delete marketplace) - cart: 1 handler (adopt cart for user) Data endpoints (reads): - blog: 4 (post-by-slug/id, posts-by-ids, search-posts) - events: 10 (pending entries/tickets, entries/tickets for page/order, entry-ids, associated-entries, calendars, visible-entries-for-period) - market: 1 (marketplaces-for-container) - cart: 1 (cart-summary) Service registration cleanup: - blog→blog+federation, events→calendar+federation, market→market+federation, cart→cart only, federation→federation only, account→nothing - Stubs reduced to minimal StubFederationService Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from decimal import Decimal
|
|
|
|
from shared.infrastructure.data_client import fetch_data
|
|
from shared.contracts.dtos import CalendarEntryDTO, TicketDTO, dto_from_dict
|
|
from .identity import current_cart_identity
|
|
|
|
|
|
async def get_calendar_cart_entries(session):
|
|
"""
|
|
Return all *pending* calendar entries (as CalendarEntryDTOs) for the
|
|
current cart identity (user or anonymous session).
|
|
"""
|
|
ident = current_cart_identity()
|
|
params = {}
|
|
if ident["user_id"] is not None:
|
|
params["user_id"] = ident["user_id"]
|
|
if ident["session_id"] is not None:
|
|
params["session_id"] = ident["session_id"]
|
|
raw = await fetch_data("events", "pending-entries", params=params, required=False) or []
|
|
return [dto_from_dict(CalendarEntryDTO, e) for e in raw]
|
|
|
|
|
|
def calendar_total(entries) -> Decimal:
|
|
"""
|
|
Total cost of pending calendar entries.
|
|
"""
|
|
return sum(
|
|
(Decimal(str(e.cost)) if e.cost else Decimal(0))
|
|
for e in entries
|
|
if e.cost is not None
|
|
)
|
|
|
|
|
|
async def get_ticket_cart_entries(session):
|
|
"""Return all reserved tickets (as TicketDTOs) for the current identity."""
|
|
ident = current_cart_identity()
|
|
params = {}
|
|
if ident["user_id"] is not None:
|
|
params["user_id"] = ident["user_id"]
|
|
if ident["session_id"] is not None:
|
|
params["session_id"] = ident["session_id"]
|
|
raw = await fetch_data("events", "pending-tickets", params=params, required=False) or []
|
|
return [dto_from_dict(TicketDTO, t) for t in raw]
|
|
|
|
|
|
def ticket_total(tickets) -> Decimal:
|
|
"""Total cost of reserved tickets."""
|
|
return sum((Decimal(str(t.price)) if t.price else Decimal(0) for t in tickets), Decimal(0))
|