Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled
34 lines
663 B
Python
34 lines
663 B
Python
"""
|
|
Referral schemas (3C.2).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ReferralKpiWindow(BaseModel):
|
|
days: int = Field(ge=1, le=365)
|
|
start: datetime
|
|
end: datetime
|
|
|
|
|
|
class ReferralReferrerRow(BaseModel):
|
|
user_id: int
|
|
email: str
|
|
invite_code: Optional[str] = None
|
|
created_at: datetime
|
|
referred_users_total: int = 0
|
|
referred_users_window: int = 0
|
|
referral_link_views_window: int = 0
|
|
|
|
|
|
class ReferralKpisResponse(BaseModel):
|
|
window: ReferralKpiWindow
|
|
totals: dict[str, int]
|
|
referrers: list[ReferralReferrerRow]
|
|
|