From 6355305d084045917607dbfa846f03d670c3ceaa Mon Sep 17 00:00:00 2001
From: "E. Joshua Rigler" <erigler@usgs.gov>
Date: Thu, 11 Aug 2022 13:33:59 -0600
Subject: [PATCH] update interval no longer shrinks with recursion

Previously, the endtime-starttime interval being processed by the
`run_as_update` method would shrink by 1 (second) with each recursion.
This ultimately broke `run_as_update` when processing anything other
than 1-second data, but it wasn't obvious because we rarely had to
actually recurse. There is a little trickery now to ensure that user-
provided starttime and endtime are inclusive of the full first
(most recent) update interval, while subsequent, calculated, endtimes
are set equal to the prior starttime minus specified output_interval
(e.g., 'second', 'minute', etc.).
---
 geomagio/Controller.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/geomagio/Controller.py b/geomagio/Controller.py
index aa717974..6d37c112 100644
--- a/geomagio/Controller.py
+++ b/geomagio/Controller.py
@@ -426,9 +426,11 @@ class Controller(object):
             # check for fillable gap at start
             if output_gap[0] == starttime:
                 # found fillable gap at start, recurse to previous interval
-                interval = endtime - starttime
-                recurse_starttime = starttime - interval
-                recurse_endtime = starttime - 1
+                delta = TimeseriesUtility.get_delta_from_interval(output_interval)
+                recurse_starttime = (
+                    starttime - (endtime - starttime) - delta * bool(update_count)
+                )
+                recurse_endtime = starttime - delta
                 self.run_as_update(
                     algorithm=algorithm,
                     observatory=observatory,
-- 
GitLab