Skip to content

Commit

Permalink
Attempt to fix nested model retrival
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Oct 3, 2024
1 parent 0bd37f5 commit b24ca81
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion opensensor/collection_apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ def create_nested_pipeline(model: Type[BaseModel], prefix="", pipeline=None):
match_conditions = {}
if pipeline is None:
pipeline = {
"_id": False,
"timestamp": "$timestamp",
}

Expand Down Expand Up @@ -397,11 +396,13 @@ def get_uniform_sample_pipeline(
}
}
}
# Add a stage to explicitly exclude _id field from the output
},
{"$group": {"_id": "$group", "doc": {"$first": "$$ROOT"}}},
{"$replaceRoot": {"newRoot": "$doc"}},
{"$project": project_pipeline},
{"$sort": {"timestamp": 1}},
{"$project": {"_id": 0}},
]

logger.info(f"Pipeline for {response_model.__name__}: {pipeline}")
Expand Down

0 comments on commit b24ca81

Please sign in to comment.