Add dashboard endpoint
This commit is contained in:
parent
3f130363d7
commit
40adda078e
2 changed files with 102 additions and 1 deletions
25
backend/app/schemas/dashboard.py
Normal file
25
backend/app/schemas/dashboard.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel
|
||||
|
||||
from app.schemas.transaction import Transaction
|
||||
from app.util.encoders import decimal_encoder
|
||||
|
||||
class DashboardStats(BaseModel):
|
||||
transaction_count: int
|
||||
transaction_count_previous: int
|
||||
transaction_energy_total: Decimal
|
||||
transaction_energy_total_previous: Decimal
|
||||
transaction_cost_total: Decimal
|
||||
transaction_cost_total_previous: Decimal
|
||||
|
||||
class Config:
|
||||
json_encoders = {Decimal: decimal_encoder}
|
||||
|
||||
class DashboardResponse(BaseModel):
|
||||
stats: DashboardStats
|
||||
current_transaction: Optional[Transaction] = None
|
||||
recent_transactions: list[Transaction]
|
||||
|
||||
class Config:
|
||||
json_encoders = {Decimal: decimal_encoder}
|
Loading…
Add table
Add a link
Reference in a new issue