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

tag_hierarchy update script

parent eb0bfb14
<?xml version="1.0" encoding="UTF-8"?>
<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">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
......
......@@ -150,9 +150,3 @@ class TagHierarchy(MongoCollectionBaseClass):
"""
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:
temp_details = list(self.site_conf.find_site_by_aggregate(each_query))
details.extend(temp_details)
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")
try:
self.tag_hierarchy.drop_tag_hierarchy_collection()
logger.info(f"Dropped {self.tag_hierarchy.collection} collection from {self.site_conf.database} database")
self.tag_hierarchy.delete_many_tag_hierarchy({})
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:
self.tag_hierarchy.insert_many_tag_hierarchy(details)
logger.info("Updated the following collection Successfully")
logger.info(
f"database_name: {self.site_conf.database} collection_name: {self.tag_hierarchy.collection}")
logger.info(f"'database_name': '{self.tag_hierarchy.database}' "
f"'collection_name': '{self.tag_hierarchy.collection}'")
print("Updated the collection Successfully")
except Exception as e:
logger.exception(str(e))
......
......@@ -214,17 +214,6 @@ class MongoCollectionBaseClass:
except Exception:
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):
"""
......
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