|
@@ -300,8 +300,14 @@ class MongodbHandler:
|
|
except Exception as error:
|
|
except Exception as error:
|
|
self._log.log_and_raise_error(('A problem occured when aggregating the collection {} with the pipeline {}. \nError: {}').format(collection_name, aggregation_pipeline, error))
|
|
self._log.log_and_raise_error(('A problem occured when aggregating the collection {} with the pipeline {}. \nError: {}').format(collection_name, aggregation_pipeline, error))
|
|
return None
|
|
return None
|
|
-
|
|
|
|
- return self.convert_mongo_data_into_dataframe(data, index, collection_name)
|
|
|
|
|
|
+ if data.collection.count_documents(aggregation_pipeline) != 0:
|
|
|
|
+ if return_as_dataframe:
|
|
|
|
+ return self.convert_mongo_data_into_dataframe(data, index, collection_name)
|
|
|
|
+ else:
|
|
|
|
+ return data
|
|
|
|
+ else:
|
|
|
|
+ self._log.warning('No data was found for the query')
|
|
|
|
+ return None
|
|
|
|
|
|
def convert_mongo_data_into_dataframe(self, data, index: str = None, collection_name: str = None, chunksize: int = 500) -> pd.DataFrame():
|
|
def convert_mongo_data_into_dataframe(self, data, index: str = None, collection_name: str = None, chunksize: int = 500) -> pd.DataFrame():
|
|
|
|
|