Skip to content

Commit

Permalink
updated migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
Lokendra-egov committed Nov 4, 2024
1 parent 6e26373 commit f37bd42
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
6 changes: 3 additions & 3 deletions utilities/PaymentTrackerMigration/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ DB_NAME=mukta_uat_db
DB_USER=muktauat
DB_PASSWORD=muktauat123

MDMS_HOST=http://egov-mdms-service.egov:8080/
MDMS_SEARCH=egov-mdms-service/v1/_search
MDMS_HOST=http://mdms-v2.egov:8080/
MDMS_SEARCH=mdms-v2/v1/_search


#IFMS_HOST=http://localhost:8080/
Expand Down Expand Up @@ -51,4 +51,4 @@ STATE_LEVEL_TENANT_ID=od
KAFKA_SERVER=kafka-kraft-controller-headless.kafka-kraft:9092
EXPENSE_BILL_INDEX_TOPIC=expense-bill-create
EXPENSE_BILL_UPDATE_TOPIC=expense-bill-update
MUKTA_PI_INDEX_TOPIC=mukta-ifix-pi-index-enrich
MUKTA_PI_INDEX_TOPIC=mukta-ifix-pi-index-internal
37 changes: 20 additions & 17 deletions utilities/PaymentTrackerMigration/app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,21 +374,21 @@ def migrate():

def process_pis(pi, tenant_id, request_info):
print(f"Processing PI for tenant_id: {tenant_id} and PI id: {pi['id']}")
bill_number = pi['additionalDetails']['billNumber']
if bill_number is not None:
bill = fetch_bill(request_info,tenant_id,bill_number[0])
if bill:
additional_details = bill['additionalDetails']
if additional_details is not None:
pi['additionalDetails']['projectId'] = additional_details['projectId']
pi['additionalDetails']['projectCreatedDate'] = additional_details['projectCreatedDate']

pi_request = {
"RequestInfo": request_info,
"paymentInstruction": pi
}
# bill_number = pi['additionalDetails']['billNumber']
# if bill_number is not None:
# bill = fetch_bill(request_info,tenant_id,bill_number[0])
# if bill:
# additional_details = bill['additionalDetails']
# if additional_details is not None:
# pi['additionalDetails']['projectId'] = additional_details['projectId']
# pi['additionalDetails']['projectCreatedDate'] = additional_details['projectCreatedDate']

pi_request = {
"RequestInfo": request_info,
"paymentInstruction": pi
}

publish_to_kafka(pi_request, os.getenv('MUKTA_PI_INDEX_TOPIC'))
publish_to_kafka(pi_request, os.getenv('MUKTA_PI_INDEX_TOPIC'))


def check_if_done_pi(pi, cursor, connection):
Expand Down Expand Up @@ -420,7 +420,7 @@ def process_pi_for_tenant(request_info, tenant_id, connection, cursor):
"limit": 100,
"offSet": 0,
"sortBy": "createdtime",
"order": "DESC"
"order": "ASC"
}
}

Expand All @@ -430,7 +430,9 @@ def process_pi_for_tenant(request_info, tenant_id, connection, cursor):
if response.status_code == 200:
response_data = response.json()
for pi in response_data.get('paymentInstructions', []):
check_if_done_pi(pi, cursor, connection)
# check_if_done_pi(pi, cursor, connection)
if check_if_done_pi(pi, cursor, connection) is True:
continue
process_pis(pi, tenant_id, request_info)
cursor.execute('''INSERT INTO PIMigrationStatus (id, migrated) VALUES (%s, %s)''', (pi['id'], True))
if len(response_data.get('paymentInstructions', [])) < int(data["pagination"]["limit"]):
Expand All @@ -442,7 +444,8 @@ def process_pi_for_tenant(request_info, tenant_id, connection, cursor):
else:
print(f"Failed to fetch data from the API. Status code: {response.status_code}")
print(response.text)
break
data["pagination"]["offSet"] = str(int(data["pagination"]["offSet"]) + 1)
# break



Expand Down

0 comments on commit f37bd42

Please sign in to comment.