Skip to content

Commit 0bde63d

Browse files
committed
attempt to resolve conflicts with migration path
1 parent 799a621 commit 0bde63d

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
@@ -110,6 +110,9 @@ def _record_data_to_ts_collection(
110110
# We go with the current time because time series collections are restricted this way
111111
model_instance.pop("timestamp", None)
112112

113+
# Translate to the combined collection field names
114+
column_name = new_collections[get_collection_name(model_instance)]
115+
113116
for key, value in model_instance.items():
114117
if value is not None:
115118
if key == "unit":
@@ -164,7 +167,7 @@ def get_uniform_sample_pipeline(
164167
start_date: datetime,
165168
end_date: datetime,
166169
resolution: int,
167-
old_collections: bool,
170+
old_collection: bool,
168171
):
169172
sampling_interval = timedelta(minutes=resolution)
170173
if start_date is None:
@@ -181,7 +184,7 @@ def get_uniform_sample_pipeline(
181184
}
182185

183186
# Determine the $project
184-
if old_collections:
187+
if old_collection:
185188
project_projection = _get_old_project_projection(response_model)
186189
else:
187190
old_name = get_collection_name(response_model)
@@ -235,7 +238,7 @@ def sample_and_paginate_collection(
235238
page: int,
236239
size: int,
237240
unit: str,
238-
old_collections: bool,
241+
old_collection: bool,
239242
):
240243
api_keys, _ = get_api_keys_by_device_id(device_id)
241244
device_ids, target_device_name = reduce_api_keys_to_device_ids(api_keys, device_id)
@@ -247,7 +250,7 @@ def sample_and_paginate_collection(
247250
start_date,
248251
end_date,
249252
resolution,
250-
old_collections,
253+
old_collection,
251254
)
252255
pipeline.extend([{"$skip": offset}, {"$limit": size}])
253256

@@ -309,7 +312,7 @@ async def historical_data_route(
309312
page=page,
310313
size=size,
311314
unit=unit,
312-
old_collections=not migration_finished,
315+
old_collection=not migration_finished,
313316
)
314317

315318
return historical_data_route

0 commit comments

Comments
 (0)