Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
ems_collector
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ZZH
ems_collector
Commits
3f34cd67
Commit
3f34cd67
authored
Jul 13, 2026
by
wwr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add water history data
parent
34522890
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
backfill_water_pg_1day.py
src/ems_water_grp/backfill_water_pg_1day.py
+6
-1
No files found.
src/ems_water_grp/backfill_water_pg_1day.py
View file @
3f34cd67
...
...
@@ -140,6 +140,10 @@ def quantize_3(value: Decimal) -> Decimal:
return
value
.
quantize
(
Decimal
(
"0.001"
),
rounding
=
ROUND_HALF_UP
)
def
non_negative
(
value
:
Decimal
)
->
Decimal
:
return
value
if
value
>=
0
else
Decimal
(
"0"
)
def
normalize_items
(
items
:
List
[
dict
])
->
List
[
Tuple
[
pendulum
.
DateTime
,
Decimal
]]:
points
=
[]
for
item
in
items
:
...
...
@@ -396,6 +400,7 @@ class WaterPgDailyBackfill:
sum
((
value
for
_
,
value
in
points
),
Decimal
(
"0"
))
/
Decimal
(
len
(
points
))
)
avg_value
=
non_negative
(
avg_value
)
pg_rows
.
append
((
device
[
"device_id"
],
device
[
"mtid"
],
...
...
@@ -406,7 +411,7 @@ class WaterPgDailyBackfill:
read_time_str
,
))
else
:
water_vol
=
last_value
-
first_value
water_vol
=
non_negative
(
last_value
-
first_value
)
water_rows
.
append
((
device
[
"device_id"
],
device
[
"mtid"
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment