feat: add API to get daily consumption
This commit is contained in:
parent
9c883a8eca
commit
a0acb2950c
18 changed files with 278 additions and 6 deletions
|
|
@ -1,3 +1,4 @@
|
|||
from .uplink_event import UplinkEvent
|
||||
from .consumption_point import ConsumptionPoint, ConsumptionResponse
|
||||
|
||||
__all__ = ["UplinkEvent"]
|
||||
__all__ = ["UplinkEvent", "ConsumptionPoint", "ConsumptionResponse"]
|
||||
19
server/app/domain/entities/consumption_point.py
Normal file
19
server/app/domain/entities/consumption_point.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from domain.value_objects import Granularity
|
||||
|
||||
@dataclass
|
||||
class ConsumptionPoint:
|
||||
period: datetime
|
||||
pulse_count_start: int
|
||||
pulse_count_end: int
|
||||
delta_pulses: int
|
||||
delta_m3: float
|
||||
|
||||
@dataclass
|
||||
class ConsumptionResponse:
|
||||
dev_eui: str
|
||||
start: datetime
|
||||
end: datetime
|
||||
granularity: Granularity
|
||||
points: list[ConsumptionPoint]
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
# domain/exceptions.py (ou dans domain.py directement)
|
||||
class DomainError(Exception):
|
||||
"""Base pour toutes les erreurs de domaine"""
|
||||
|
||||
class InfrastructureError(Exception):
|
||||
"""Erreur technique levée par un adapter"""
|
||||
|
|
@ -10,4 +11,7 @@ class DatabaseError(InfrastructureError):
|
|||
"""Erreur lors d'une opération en base de données."""
|
||||
|
||||
class MessageBrokerError(InfrastructureError):
|
||||
"""Impossible de se connecter au broker MQTT"""
|
||||
"""Impossible de se connecter au broker MQTT"""
|
||||
|
||||
class ValidationError(DomainError):
|
||||
"""Données d'entrée invalides"""
|
||||
|
|
|
|||
3
server/app/domain/value_objects.py
Normal file
3
server/app/domain/value_objects.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from typing import Literal
|
||||
|
||||
Granularity = Literal["hour", "day", "month"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue