@@ -181,11 +181,16 @@ def normalize_ref(self, ref: "DataReference") -> None:
181181 def on_file_added (self , path : str , refs : List ["DataReference" ]) -> None :
182182 """Hook called after a file's refs have been successfully added.
183183
184- Override to perform file-level side effects such as expanding
185- ``self.time_range``, loading geometry from a companion file, or
186- registering the source in an external index.
184+ Default implementation: expands ``self.time_range`` to cover the
185+ data extent of any newly added refs. Readers declare their data's
186+ time extent by storing ``time_extent_start`` and ``time_extent_end``
187+ attributes (ISO-8601 strings or any ``pd.Timestamp``-coercible value)
188+ on each :class:`~dvue.catalog.DataReference`.
187189
188- The default is a no-op.
190+ Subclasses that need additional side-effects (loading geometry,
191+ registering external indices, etc.) should call
192+ ``super().on_file_added(path, refs)`` so that time_range expansion
193+ still happens.
189194
190195 Parameters
191196 ----------
@@ -195,6 +200,37 @@ def on_file_added(self, path: str, refs: List["DataReference"]) -> None:
195200 All refs returned by ``ReaderRegistry.scan(path)`` for this file
196201 (including any that were skipped due to pk collisions).
197202 """
203+ starts = []
204+ ends = []
205+ seen : set = set ()
206+ for ref in refs :
207+ s = ref ._attributes .get ("time_extent_start" )
208+ e = ref ._attributes .get ("time_extent_end" )
209+ key = (s , e )
210+ if key in seen or not s :
211+ continue
212+ seen .add (key )
213+ try :
214+ starts .append (pd .Timestamp (s ))
215+ except Exception :
216+ pass
217+ if e :
218+ try :
219+ ends .append (pd .Timestamp (e ))
220+ except Exception :
221+ pass
222+ if not starts :
223+ return
224+ new_start = min (starts )
225+ new_end = max (ends ) if ends else new_start + pd .Timedelta (days = 366 )
226+ current = self .time_range
227+ if current is None :
228+ self .time_range = (new_start , new_end )
229+ else :
230+ self .time_range = (
231+ min (current [0 ], new_start ),
232+ max (current [1 ], new_end ),
233+ )
198234
199235 # ------------------------------------------------------------------
200236 # Geo / map integration
0 commit comments