refactor auto import

This commit is contained in:
hsafaei
2025-01-18 15:32:25 +03:30
parent a5da45d7a5
commit c1ef81c632
31 changed files with 1613 additions and 1123 deletions
+6 -4
View File
@@ -7,10 +7,9 @@ from html import escape
import json
from decimal import Decimal
import datetime
from config_base import *
from general_functions import *
from text_normalizer import TextNormalizer
def import_lawreg_lwphase_info(cursor):
query='SELECT ID,CAPTION FROM [Qavanin].[dbo].[cmOrganization]'
@@ -27,7 +26,7 @@ def import_lawreg_lwphase_info(cursor):
rr = {"id" : int(row.ID), 'title': row.CAPTION}
ORG_DICT[str(int(row.ID))] = {"id" : row.ID, 'title': row.CAPTION}
#نکته : برای مقررات هیچ موردی نبود که جدولی باشد
query = '''
SELECT
@@ -49,6 +48,7 @@ def import_lawreg_lwphase_info(cursor):
'''
cursor.execute(query)
text_normal = TextNormalizer()
url = BASE_URL + "repo/majles/qaqanon/multi/update"
@@ -185,6 +185,7 @@ def import_lawreg_lwphase_info(cursor):
response = requests.request("POST", url, headers=headers, data=payload)
if response.status_code != 200 :
print(bulk_data)
print(response.text)
bulk_data = []
break
@@ -202,7 +203,8 @@ def import_lawreg_lwphase_info(cursor):
print('=' * 10, ' lawreg_lwphase_info , total='+str(total_count) )
payload = json.dumps(bulk_data, cls=JSONEncoder) #Works!
response = requests.request("POST", url, headers=headers, data=payload)
if response.status_code == 500 :
if response.status_code != 200 :
print(bulk_data)
print(response.text)
bulk_data = []