Skip to content

Commit 8bbe02f

Browse files
committed
Ensure start and end date are in fact set
1 parent b3f991d commit 8bbe02f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

opensensor/collection_apis.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,6 @@ def get_initial_match_clause(
163163
start_date: datetime,
164164
end_date: datetime,
165165
):
166-
if start_date is None:
167-
start_date = datetime.utcnow() - timedelta(days=100)
168-
if end_date is None:
169-
end_date = datetime.utcnow()
170-
171166
# Defining the match clause for the pipeline
172167
match_clause = {
173168
"timestamp": {"$gte": start_date, "$lte": end_date},
@@ -187,6 +182,10 @@ def get_vpd_pipeline(
187182
resolution: int,
188183
):
189184
sampling_interval = timedelta(minutes=resolution)
185+
if start_date is None:
186+
start_date = datetime.utcnow() - timedelta(days=100)
187+
if end_date is None:
188+
end_date = datetime.utcnow()
190189
match_clause = get_initial_match_clause(device_ids, device_name, start_date, end_date)
191190
match_clause["temp"] = {"$exists": True}
192191
match_clause["rh"] = {"$exists": True}
@@ -263,6 +262,10 @@ def get_uniform_sample_pipeline(
263262
end_date: datetime,
264263
resolution: int,
265264
):
265+
if start_date is None:
266+
start_date = datetime.utcnow() - timedelta(days=100)
267+
if end_date is None:
268+
end_date = datetime.utcnow()
266269
sampling_interval = timedelta(minutes=resolution)
267270
match_clause = get_initial_match_clause(
268271
device_ids, device_name, start_date, end_date, resolution

0 commit comments

Comments
 (0)