From f37bd42617a16c095daf38958ffaffd81b057ed4 Mon Sep 17 00:00:00 2001 From: Lokendra Tyagi Date: Mon, 4 Nov 2024 14:02:46 +0530 Subject: [PATCH] updated migration script --- utilities/PaymentTrackerMigration/.env | 6 +-- .../PaymentTrackerMigration/app/controller.py | 37 ++++++++++--------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/utilities/PaymentTrackerMigration/.env b/utilities/PaymentTrackerMigration/.env index d656ede5eb..1f3a461029 100644 --- a/utilities/PaymentTrackerMigration/.env +++ b/utilities/PaymentTrackerMigration/.env @@ -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/ @@ -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 \ No newline at end of file +MUKTA_PI_INDEX_TOPIC=mukta-ifix-pi-index-internal \ No newline at end of file diff --git a/utilities/PaymentTrackerMigration/app/controller.py b/utilities/PaymentTrackerMigration/app/controller.py index 6d9d35bc7c..0427133577 100644 --- a/utilities/PaymentTrackerMigration/app/controller.py +++ b/utilities/PaymentTrackerMigration/app/controller.py @@ -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): @@ -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" } } @@ -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"]): @@ -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