fix: use explicit mapping in Consumption Point Schema
This commit is contained in:
parent
5f15002462
commit
2341471e0e
1 changed files with 13 additions and 2 deletions
|
|
@ -3,6 +3,7 @@ from pydantic import BaseModel
|
|||
|
||||
from domain.entities import ConsumptionResponse
|
||||
|
||||
|
||||
class ConsumptionPointSchema(BaseModel):
|
||||
period: datetime
|
||||
pulse_count_start: int
|
||||
|
|
@ -10,6 +11,7 @@ class ConsumptionPointSchema(BaseModel):
|
|||
delta_pulses: int
|
||||
delta_m3: float
|
||||
|
||||
|
||||
class ConsumptionResponseSchema(BaseModel):
|
||||
dev_eui: str
|
||||
start: datetime
|
||||
|
|
@ -24,5 +26,14 @@ class ConsumptionResponseSchema(BaseModel):
|
|||
start=r.start,
|
||||
end=r.end,
|
||||
granularity=r.granularity,
|
||||
points=[ConsumptionPointSchema(**p.__dict__) for p in r.points],
|
||||
)
|
||||
points=[
|
||||
ConsumptionPointSchema(
|
||||
period=p.period,
|
||||
pulse_count_start=p.pulse_count_start,
|
||||
pulse_count_end=p.pulse_count_end,
|
||||
delta_pulses=p.delta_pulses,
|
||||
delta_m3=p.delta_m3,
|
||||
)
|
||||
for p in r.points
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue