just in case
This commit is contained in:
@@ -276,10 +276,19 @@ def get_period_totals(start, end, task=None):
|
|||||||
return [{"ws": "No Data", "total": ""}]
|
return [{"ws": "No Data", "total": ""}]
|
||||||
|
|
||||||
bfirst = aux_results[0]["before_first"]
|
bfirst = aux_results[0]["before_first"]
|
||||||
|
start_delta = 0
|
||||||
|
|
||||||
if bfirst:
|
if bfirst:
|
||||||
bfdate = bfirst["date"].replace(tzinfo=utctz)
|
bfdate = bfirst["date"].replace(tzinfo=utctz)
|
||||||
start_delta = round((start - bfdate.astimezone(timezone)).total_seconds())
|
time_since_bfirst = round((start - bfdate.astimezone(timezone)).total_seconds())
|
||||||
|
|
||||||
|
# Only apply start_delta if the before_first switch actually crosses into the period
|
||||||
|
# If time_since_bfirst > bfirst["delta"], the switch ended before the period started
|
||||||
|
if time_since_bfirst <= bfirst["delta"]:
|
||||||
|
start_delta = time_since_bfirst
|
||||||
|
logger.debug(f"start_delta: {start_delta}s (bfirst crosses into period)")
|
||||||
|
else:
|
||||||
|
logger.debug(f"start_delta: 0s (bfirst ended before period start: {time_since_bfirst}s > {bfirst['delta']}s)")
|
||||||
|
|
||||||
ldoc = aux_results[0]["last_doc"]
|
ldoc = aux_results[0]["last_doc"]
|
||||||
lastdate = ldoc["date"].replace(tzinfo=utctz)
|
lastdate = ldoc["date"].replace(tzinfo=utctz)
|
||||||
|
|||||||
Reference in New Issue
Block a user