refactor auto import
This commit is contained in:
@@ -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_relations_qanon_opinion(cursor):
|
||||
# اجرای کوئری SQL و خواندن دادهها به یک DataFrame
|
||||
@@ -39,6 +38,7 @@ def import_relations_qanon_opinion(cursor):
|
||||
"""
|
||||
|
||||
cursor.execute(query)
|
||||
text_normal = TextNormalizer()
|
||||
|
||||
url = BASE_URL + "repo/majles/qaqanon/multi/update"
|
||||
|
||||
@@ -95,9 +95,9 @@ def import_relations_qanon_opinion(cursor):
|
||||
|
||||
from_section_title = ''
|
||||
if row.from_section_title :
|
||||
from_section_title = row.from_section_title
|
||||
from_section_title = text_normal.normalize_qanon(row.from_section_title)
|
||||
|
||||
to_title = normalYehKe( row.to_title )
|
||||
to_title = text_normal.normalize_qanon( row.to_title )
|
||||
|
||||
|
||||
to_type = ''
|
||||
@@ -164,7 +164,8 @@ def import_relations_qanon_opinion(cursor):
|
||||
|
||||
|
||||
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 = []
|
||||
break
|
||||
@@ -176,7 +177,7 @@ def import_relations_qanon_opinion(cursor):
|
||||
|
||||
|
||||
|
||||
if len(relations) :
|
||||
if len(relations) > 0 :
|
||||
data={
|
||||
'id' : prev_eid,
|
||||
'opinion_relations' : relations
|
||||
@@ -197,10 +198,13 @@ def import_relations_qanon_opinion(cursor):
|
||||
|
||||
response = requests.request("POST", url, headers=headers, data=payload)
|
||||
if response.status_code != 200 :
|
||||
print(bulk_data)
|
||||
print(response.text)
|
||||
bulk_data = []
|
||||
|
||||
bulk_data = pops_data
|
||||
if not bulk_data :
|
||||
break
|
||||
|
||||
|
||||
t2= datetime.datetime.now()
|
||||
|
||||
Reference in New Issue
Block a user