Skip to content

Commit

Permalink
Merge pull request #24 from KathreftisAI/qa-release
Browse files Browse the repository at this point in the history
Qa release
  • Loading branch information
unileshyadav authored Apr 24, 2024
2 parents 76b05e4 + 9b88d10 commit 4aa4907
Show file tree
Hide file tree
Showing 3 changed files with 364 additions and 232 deletions.
3 changes: 3 additions & 0 deletions database/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pymongo import MongoClient
from config.loader import Configuration
import platform
import logging

def load_configuration():
if platform.system() == 'Windows':
Expand All @@ -21,4 +22,6 @@ def get_collection(tenant_name: str, collection_name: str):
mongo_tenant_details = BASE_TENANT_STRING % tenant_name
database = mongo_client[mongo_tenant_details]
generic_collection = database[collection_name]
# logging.debug(f"got database {database}")
# logging.debug(f"info of database {mongo_tenant_details}")
return generic_collection
43 changes: 34 additions & 9 deletions database/watcher/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def process_new_sync_data_for_recon(tenant, new_document):

redis_key = f"recon_{tenant}_{rcId}"
logging.debug(f"Redis key found: {redis_key}")
recon_report_metadata_id = redis_client.hget(redis_key, 'reconReportMetadataId')
reconciliationId = redis_client.hget(redis_key, "reconciliationId")
#batch_id = redis_client.hget(key, 'batchId')
appId = redis_client.hget(redis_key, 'appId')
Expand Down Expand Up @@ -259,7 +258,8 @@ def process_new_sync_data_for_recon(tenant, new_document):
returnval = True

login_break_count = getBreakCount(tenant,reconciliationId,login)


present_in_target_only = []
if login not in all_cymmetri_logins_redis_data:
logging.debug(f"User login {login} found in target app only.")
record = {
Expand All @@ -273,10 +273,18 @@ def process_new_sync_data_for_recon(tenant, new_document):
"login":login,
"break_count":login_break_count
}
shReconBreakRecords.insert_one(record)

#shReconBreakRecords.insert_one(record)
present_in_target_only.append(record)
try:
shReconBreakRecords.insert_many(present_in_target_only)
logging.debug("Data Inserted for present_in_target_only into shReconBreakRecords succesfully.")
except Exception as e:
logging.error(f"Failed to insert data for present_in_target_only into shReconBreakRecords collection: {e}")




app_overdue = []
if login in final_app_overdue_redis_data:
logging.debug(f'user {login} should have been disabled but is still in target app')
record = {
Expand All @@ -290,7 +298,14 @@ def process_new_sync_data_for_recon(tenant, new_document):
"login":login,
"break_count": login_break_count
}
shReconBreakRecords.insert_one(record)
#shReconBreakRecords.insert_one(record)
app_overdue.append(record)
try:
shReconBreakRecords.insert_many(app_overdue)
logging.debug("Data Inserted for app_overdue into shReconBreakRecords succesfully.")
except Exception as e:
logging.error(f"Failed to insert data for app_overdue into shReconBreakRecords collection: {e}")

logging.debug("Process for syncdata for recon insert data is completed.")
return returnval

Expand All @@ -302,6 +317,8 @@ def getBreakCount(tenant, reconciliationId, login):

def execute_final_code(tenant, reconciliationId):

login_data = []

logging.info(f"Starting final execution for tenant: {tenant}, reconciliationId: {reconciliationId}")

shReconBreakRecords = get_collection(tenant, 'shReconBreakRecords')
Expand All @@ -328,7 +345,6 @@ def execute_final_code(tenant, reconciliationId):

logging.debug(f"Retrieved from Redis - appId: {appId}, appName: {appName}, reconReportMetadataId: {rrMetaId}")


for i in full_set_of_target_logins:
try:
full_set_of_cymmetri_logins.remove(i)
Expand All @@ -339,7 +355,7 @@ def execute_final_code(tenant, reconciliationId):
#only_present_in_Cymmetri = full_set_of_cymmetri_logins - full_set_of_target_logins

#print(full_set_of_cymmetri_logins)

for login in full_set_of_cymmetri_logins:
#print(f'{login} only found in cymmetri')
login_break_count = getBreakCount(tenant, reconciliationId,login)
Expand All @@ -354,8 +370,17 @@ def execute_final_code(tenant, reconciliationId):
"login":login,
"break_count": login_break_count
}
shReconBreakRecords.insert_one(record)
#logging.debug(f"Inserted break record for login {login}: {record.inserted_id}")
#shReconBreakRecords.insert_one(record)

login_data.append(record)
try:
shReconBreakRecords.insert_many(login_data)
logging.debug("Data Inserted into shReconBreakRecords succesfully.")
except Exception as e:
logging.error(f"Failed to insert data into shReconBreakRecords collection: {e}")




break_types = ["present_in_target_only", "present_in_Cymmetri_only", "app_overdue"]

Expand Down
Loading

0 comments on commit 4aa4907

Please sign in to comment.