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_lwreg(cursor):
|
||||
@@ -38,6 +37,7 @@ def import_relations_qanon_lwreg(cursor):
|
||||
"""
|
||||
|
||||
cursor.execute(query)
|
||||
text_normal = TextNormalizer()
|
||||
|
||||
url = BASE_URL + "repo/majles/qaqanon/multi/update"
|
||||
|
||||
@@ -105,9 +105,9 @@ def import_relations_qanon_lwreg(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 = row.to_type
|
||||
|
||||
|
||||
@@ -140,8 +140,8 @@ def import_relations_qanon_lwreg(cursor):
|
||||
}
|
||||
|
||||
total_count = total_count+1
|
||||
if total_count < 2560 :
|
||||
continue
|
||||
# if total_count < 2560 :
|
||||
# continue
|
||||
|
||||
bulk_data.append(data)
|
||||
|
||||
@@ -198,12 +198,14 @@ def import_relations_qanon_lwreg(cursor):
|
||||
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 = []
|
||||
|
||||
bulk_data = pops_data
|
||||
if not bulk_data :
|
||||
break
|
||||
|
||||
|
||||
t2= datetime.datetime.now()
|
||||
|
||||
Reference in New Issue
Block a user