Add type field

This commit is contained in:
2026-01-04 15:21:03 +01:00
parent 2d657aaa88
commit 03de58bd51
4 changed files with 35 additions and 15 deletions

View File

@@ -23,8 +23,14 @@ class TelemetryController:
try:
odata_filter = request.args.get("$filter")
start_timestamp, end_timestamp = self._extract_dates_from_odata(odata_filter)
result = self._database_service.find_by_date("telemetry", start_timestamp, end_timestamp)
return jsonify({"success" : True, "data" : result}), 200
results = self._database_service.find_by_date(
collection="telemetry",
filters={"type": "sound"},
timestamp_field="timestamp",
start_time=start_timestamp,
end_time=end_timestamp
)
return jsonify({"success" : True, "data" : results}), 200
except Exception as e:
logger.log_info(e)
return jsonify({"success": False, "data": None}), 500
@@ -33,8 +39,14 @@ class TelemetryController:
try:
odata_filter = request.args.get("$filter")
start_timestamp, end_timestamp = self._extract_dates_from_odata(odata_filter)
result = self._database_service.find_by_date("telemetry", start_timestamp, end_timestamp)
return jsonify({"success" : True, "data" : result}), 200
results = self._database_service.find_by_date(
collection="telemetry",
filters={"type": "light"},
timestamp_field="timestamp",
start_time=start_timestamp,
end_time=end_timestamp
)
return jsonify({"success" : True, "data" : results}), 200
except Exception as e:
logger.log_info(e)
return jsonify({"success": False, "data": None}), 500
@@ -44,8 +56,14 @@ class TelemetryController:
try:
odata_filter = request.args.get("$filter")
start_timestamp, end_timestamp = self._extract_dates_from_odata(odata_filter)
result = self._database_service.find_by_date("telemetry", start_timestamp, end_timestamp)
return jsonify({"success" : True, "data" : result}), 200
results = self._database_service.find_by_date(
collection="telemetry",
filters={"type": "gps"},
timestamp_field="timestamp",
start_time=start_timestamp,
end_time=end_timestamp
)
return jsonify({"success" : True, "data" : results}), 200
except Exception as e:
logger.log_info(e)
return jsonify({"success": False, "data": None}), 500

View File

@@ -35,7 +35,8 @@ class MongoService:
except Exception as e:
logger.log_info(e)
def find_by_date(self, collection: str, filters: dict = None, timestamp_field: str = "created_at",
def find_by_date(self, collection: str,
filters: dict = None, timestamp_field: str = "created_at",
start_time: int = None, end_time: int = None):
try:
collection = self._db[collection]