Browse Source

Add fallback in case aggregate doesnt return any data

ogert 4 years ago
parent
commit
295353021c
1 changed files with 2 additions and 2 deletions
  1. 2 2
      cdplib/db_handlers/MongodbHandler.py

+ 2 - 2
cdplib/db_handlers/MongodbHandler.py

@@ -300,7 +300,7 @@ class MongodbHandler:
         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))
             return None
-         if data.collection.count_documents(aggregation_pipeline) != 0:
+        if data.collection.count_documents(aggregation_pipeline) != 0:
             if return_as_dataframe:
                 return self.convert_mongo_data_into_dataframe(data, index, collection_name)
             else:
@@ -349,7 +349,7 @@ class MongodbHandler:
         if len(frames) > 1:
             return_df = pd.concat(frames, axis=0, sort=False)
         else:
-            if not frames:
+            if len(frames) == 0:
                 self._log.warning('Query returned empty Cursor')
                 return_df = pd.DataFrame()
             else: