Commit 5044bbbf authored by Sabari T's avatar Sabari T

tag_hierarchy update script

parent eb0bfb14
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CommitMessageInspectionProfile">
<profile version="1.0">
<inspection_tool class="CommitFormat" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CommitNamingConvention" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
......
...@@ -150,9 +150,3 @@ class TagHierarchy(MongoCollectionBaseClass): ...@@ -150,9 +150,3 @@ class TagHierarchy(MongoCollectionBaseClass):
""" """
return self.delete_one(query=query) return self.delete_one(query=query)
def drop_tag_hierarchy_collection(self):
"""
The following function will delete whole tag_hierarchy collection
:return:
"""
return self.drop()
...@@ -20,16 +20,19 @@ class UpdateHandler: ...@@ -20,16 +20,19 @@ class UpdateHandler:
temp_details = list(self.site_conf.find_site_by_aggregate(each_query)) temp_details = list(self.site_conf.find_site_by_aggregate(each_query))
details.extend(temp_details) details.extend(temp_details)
logger.info("Records fetched from following collection Successfully") logger.info("Records fetched from following collection Successfully")
logger.info(f"database_name: {self.site_conf.database} collection_name: {self.site_conf.collection}") logger.info(f"'database_name': '{self.site_conf.database}' 'collection_name': '{self.site_conf.collection}'")
print("Records Fetched Successfully") print("Records Fetched Successfully")
try: try:
self.tag_hierarchy.drop_tag_hierarchy_collection() self.tag_hierarchy.delete_many_tag_hierarchy({})
logger.info(f"Dropped {self.tag_hierarchy.collection} collection from {self.site_conf.database} database") logger.info(f"Deleted all records from following collection")
logger.info(f"'database_name': '{self.tag_hierarchy.database}' "
f"'collection_name': '{self.tag_hierarchy.collection}'")
# for each_detail in details: # for each_detail in details:
self.tag_hierarchy.insert_many_tag_hierarchy(details) self.tag_hierarchy.insert_many_tag_hierarchy(details)
logger.info("Updated the following collection Successfully") logger.info("Updated the following collection Successfully")
logger.info( logger.info(f"'database_name': '{self.tag_hierarchy.database}' "
f"database_name: {self.site_conf.database} collection_name: {self.tag_hierarchy.collection}") f"'collection_name': '{self.tag_hierarchy.collection}'")
print("Updated the collection Successfully") print("Updated the collection Successfully")
except Exception as e: except Exception as e:
logger.exception(str(e)) logger.exception(str(e))
......
...@@ -214,17 +214,6 @@ class MongoCollectionBaseClass: ...@@ -214,17 +214,6 @@ class MongoCollectionBaseClass:
except Exception: except Exception:
raise raise
def drop(self):
try:
database_name = self.database
collection_name = self.collection
db = self.client[database_name]
collection = db[collection_name]
response = collection.drop()
return response
except Exception:
raise
def find_count(self, json_data, database_name, collection_name): def find_count(self, json_data, database_name, collection_name):
""" """
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment