|
@@ -293,14 +293,20 @@ class MongodbHandler:
|
|
else:
|
|
else:
|
|
return data
|
|
return data
|
|
|
|
|
|
- def query_and_insert_into_collection(self,
|
|
|
|
|
|
+ def aggregate_and_insert_into_collection(self,
|
|
input_collection_name: str,
|
|
input_collection_name: str,
|
|
output_collection_name: str,
|
|
output_collection_name: str,
|
|
- query: dict = None):
|
|
|
|
|
|
+ aggregation_pipeline: list = None):
|
|
"""
|
|
"""
|
|
"""
|
|
"""
|
|
- self._database[output_collection_name].insert(
|
|
|
|
- self._database[input_collection_name].find({}).toArray())
|
|
|
|
|
|
+ if aggregation_pipeline is None:
|
|
|
|
+ aggregation_pipeline = [{"$out": output_collection_name}]
|
|
|
|
+ else:
|
|
|
|
+ aggregation_pipeline.append({"$out": output_collection_name})
|
|
|
|
+
|
|
|
|
+ self.aggregate_data_and_generate_dataframe(
|
|
|
|
+ collection_name=input_collection_name,
|
|
|
|
+ aggregation_pipeline=aggregation_pipeline)
|
|
|
|
|
|
def aggregate_data_and_generate_dataframe(self, collection_name: str, aggregation_pipeline: list, index: str = None, return_as_dataframe=True):
|
|
def aggregate_data_and_generate_dataframe(self, collection_name: str, aggregation_pipeline: list, index: str = None, return_as_dataframe=True):
|
|
|
|
|
|
@@ -549,14 +555,14 @@ class MongodbHandler:
|
|
data = self._database[collection_name].distinct(key)
|
|
data = self._database[collection_name].distinct(key)
|
|
|
|
|
|
return data
|
|
return data
|
|
-
|
|
|
|
|
|
+
|
|
def get_number_of_entries_in_collection(self, collection_name: str):
|
|
def get_number_of_entries_in_collection(self, collection_name: str):
|
|
-
|
|
|
|
|
|
+
|
|
assert(isinstance(collection_name, str)),\
|
|
assert(isinstance(collection_name, str)),\
|
|
"Parameter 'collection_name' must be a string type"
|
|
"Parameter 'collection_name' must be a string type"
|
|
-
|
|
|
|
|
|
+
|
|
data = self._database[collection_name].count()
|
|
data = self._database[collection_name].count()
|
|
-
|
|
|
|
|
|
+
|
|
return data
|
|
return data
|
|
|
|
|
|
|
|
|