fix: replace magic number by constant
This commit is contained in:
parent
914235064c
commit
0948dbda49
1 changed files with 3 additions and 4 deletions
|
|
@ -17,7 +17,7 @@ _GRANULARITY_DELTA = {
|
||||||
"week": relativedelta(weeks=1),
|
"week": relativedelta(weeks=1),
|
||||||
"month": relativedelta(months=1),
|
"month": relativedelta(months=1),
|
||||||
}
|
}
|
||||||
|
PULSE_CONVERSION_FACTOR = 0.010
|
||||||
|
|
||||||
class PgReadingQueryRepository(ReadingQueryRepository):
|
class PgReadingQueryRepository(ReadingQueryRepository):
|
||||||
def get_consumption(
|
def get_consumption(
|
||||||
|
|
@ -65,14 +65,13 @@ class PgReadingQueryRepository(ReadingQueryRepository):
|
||||||
pulse_count_start=row[1],
|
pulse_count_start=row[1],
|
||||||
pulse_count_end=row[2],
|
pulse_count_end=row[2],
|
||||||
delta_pulses=row[3],
|
delta_pulses=row[3],
|
||||||
delta_m3=round(row[3] * 0.010, 3),
|
delta_m3=round(row[3] * PULSE_CONVERSION_FACTOR, 3),
|
||||||
)
|
)
|
||||||
for row in rows
|
for row in rows
|
||||||
if row[1] is not None
|
if row[1] is not None
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PgReadingRepository(ReadingRepository):
|
class PgReadingRepository(ReadingRepository):
|
||||||
def insert_reading(self, device_id: str, pulse_count: int) -> None:
|
def insert_reading(self, device_id: str, pulse_count: int) -> None:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue