fix bug tokens

This commit is contained in:
hsafaei
2025-04-15 15:17:00 +03:30
parent c84c635055
commit 302f6b5cd8
4 changed files with 70 additions and 75 deletions
+19 -19
View File
@@ -29,43 +29,43 @@ from s11_Tanghih_plan_move import *
# DELETE mj_qa_opinion_temp # DELETE mj_qa_opinion_temp
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# cursor, cnxn = create_cursor() cursor, cnxn = create_cursor()
# ## ایجاد فهرست موضوعات قانون ## ایجاد فهرست موضوعات قانون
# projectid = insertProejct() projectid = insertProejct()
# insertProjectItems(cursor, projectid) insertProjectItems(cursor, projectid)
# # 2 # 2
# import_law_section_to_elastic(cursor) import_law_section_to_elastic(cursor)
# import_opinion_to_elastic(cursor) import_opinion_to_elastic(cursor)
# import_regulation_section_to_elastic(cursor) import_regulation_section_to_elastic(cursor)
# ### از ابتدا تا اینجا حدودا 24 ساعت کشید ### از ابتدا تا اینجا حدودا 24 ساعت کشید
# import_law_section_update_ref_state(cursor) import_law_section_update_ref_state(cursor)
# import_regulation_section_update_ref_state(cursor) import_regulation_section_update_ref_state(cursor)
# import_law_reg_qanon_to_elastic(cursor) import_law_reg_qanon_to_elastic(cursor)
# ## تا اینجا رسید و خطا داد ## تا اینجا رسید و خطا داد
# import_relations_qanon_lwreg(cursor) import_relations_qanon_lwreg(cursor)
# ## اینجا خطا داد ## اینجا خطا داد
# import_relations_qanon_opinion(cursor) import_relations_qanon_opinion(cursor)
# import_lawreg_lwphase_info(cursor) import_lawreg_lwphase_info(cursor)
# cursor.close() cursor.close()
# cnxn.close() cnxn.close()
cursor, cnxn = create_cursor('db4minaei') cursor, cnxn = create_cursor('db4minaei')
+1
View File
@@ -5,6 +5,7 @@ import pyodbc
# و باید توکن معتبر جدید از سایت قوانین درحالت لاگین شده، # و باید توکن معتبر جدید از سایت قوانین درحالت لاگین شده،
# دریافت شود و به جای توکن زیر جایگزین شود # دریافت شود و به جای توکن زیر جایگزین شود
# TOKEN = 'eyJ0eXAiOiJKV1QiLC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bnVsbCwiZXhwIjoxNzQ1MTU0NDEwLCJhdWQiOm51bGwsImRhdGEiOnsiaWQiOjEsImZpcnN0X25hbWUiOiJcdTA2NDVcdTA2MmZcdTA2Y2NcdTA2MzEgXHUwNjQxXHUwNjQ2XHUwNmNjIiwibGFzdF9uYW1lIjoiXHUwNjMzXHUwNjI3XHUwNjQ1XHUwNjI3XHUwNjQ2XHUwNjQ3IiwiZW1haWwiOiJkZXZAZ21haWwuY29tIiwidXNlcm5hbWUiOiJkZXYiLCJ1c2VyX2xldmVsIjoyfX0.jke3m7QD2pj7E18fBJYjiz9FrYbl6ZxVaYbLt9jfZu0'
ACCEPT = "application/json" ACCEPT = "application/json"
HEADERS = {"Authorization": TOKEN, "Accept": ACCEPT} HEADERS = {"Authorization": TOKEN, "Accept": ACCEPT}
+37 -43
View File
@@ -16,14 +16,19 @@ from temp_LawSection_content import *
load_dotenv(dotenv_path='config.env') load_dotenv(dotenv_path='config.env')
host=os.getenv('HOST_160') # host=os.getenv('HOST_160')
password=os.getenv('HOST_160_PASS') # password=os.getenv('HOST_160_PASS')
# host=os.getenv('HOST_112') # host=os.getenv('HOST_112')
# password=os.getenv('HOST_112_PASS') # password=os.getenv('HOST_112_PASS')
# host=os.getenv('HOST_60') host=os.getenv('HOST_60')
# password=os.getenv('HOST_60_PASS') password=os.getenv('HOST_60_PASS')
# host=os.getenv('HOST_161')
# password=os.getenv('HOST_161_PASS')
# host=os.getenv('HOST_80') # host=os.getenv('HOST_80')
# password=os.getenv('HOST_80_PASS') # password=os.getenv('HOST_80_PASS')
@@ -74,60 +79,49 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# elastic.createIndex('mj_qa_section', 'majles', 'mj_qa_section') # elastic.createIndex('mj_qa_section', 'majles', 'mj_qa_section')
# elastic.zipFileToElastic(path_back, 'mj_qa_section') # elastic.zipFileToElastic(path_back, 'mj_qa_section')
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_log_action") #selastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha")
# elastic.backupIndexToZipfile("G:/Project2/111", "gn_calendar")
#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section") #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section")
#elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section_ai") # elastic.backupIndexToZipfile("G:/Project2/111", "dh_haditha")
#elastic.backupIndexToZipfile("G:/Project2/111", "dh_volume_temp")
#elastic.restorFileToElastic("G:/Project2/111", "mj_qa_section_ai", 'majles', True, "mj_qa_section") #elastic.restorFileToElastic("G:/Project2/111", "mj_qa_section_ai", 'majles', True, "mj_qa_section")
# elastic.restorFileToElastic('G:/Project2/111', 'dh_haditha', 'dhadith', 'dh_haditha' )
elastic.restorFileToElastic('G:/Project2/111', 'gn_calendar')
body= { body= {
"query": { "query": {
"bool": { "terms": {
"must": [ "qanon_id": [
{ "qq83354",
"bool": { "qq83382",
"should": [ "qq112748",
{ "qq112296",
"match_phrase": { "qq83435",
"title.ph": { "qq114127",
"query": "نسخ ضمنی", "qq175888",
"boost": 10 "qq85335",
} "qq84208",
} "qq114652",
}, "qq114640"
{
"match_phrase": {
"content.ph": {
"query": "نسخ ضمنی",
"boost": 10
}
}
}
] ]
} }
}, },
"sort": [
{ {
"bool": { "qanon_id": {
"filter": { "order": "asc"
"bool": { },
"must": [ "child_order": {
{ "order": "asc"
"term": {
"ts_ref.keyword": "اداره کل حقوقی قوه قضاییه"
} }
} }
] ]
} }
}
}
}
]
}
}
}
# elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_opinion", "mj_qa_opinion_naskh", body, False, ["content"]) #elastic.backupIndexToZipfile("G:/Project2/111", "mj_qa_section", "mj_qa_section_Aab", body, False, ["content", "simplifies", "tcode_sub_old", "tcode_main_old", "code-ai", "ai_keywords"])
#------------------------------------------------------- #-------------------------------------------------------
#### فایده ای نداشت ....!!! #### فایده ای نداشت ....!!!
@@ -185,7 +179,7 @@ path_back = 'G:/Project2/111'
# path_back = 'G:/Project2/_back/back_data/data_majles/elastic/v1.0/full' # path_back = 'G:/Project2/_back/back_data/data_majles/elastic/v1.0/full'
# elastic.restorFileToElastic(path_back, 'mj_qa_section', 'majles') # elastic.restorFileToElastic(path_back, 'mj_qa_section', 'majles')
elastic.restorFileToElastic(path_back, 'gn_log_action') # elastic.restorFileToElastic(path_back, 'gn_log_action')
#------------------------------------------------------- #-------------------------------------------------------
+3 -3
View File
@@ -128,8 +128,8 @@ def exportTokensToFile(elastic, index_name_i, filename, fields=['content'], body
def diff_files_to_file(file_dict1, file_dict2, filename, path_out="./data/"): def diff_files_to_file(file_dict1, file_dict2, filename, path_out="./data/"):
dict1 = json.loads(open(file_dict1, "r", encoding="utf-8").read()) dict1 = json.loads(open(path_out+file_dict1, "r", encoding="utf-8").read())
dict2 = json.loads(open(file_dict2, "r", encoding="utf-8").read()) dict2 = json.loads(open(path_out+file_dict2, "r", encoding="utf-8").read())
return diff_to_file(dict1, dict2, filename, False, path_out) return diff_to_file(dict1, dict2, filename, False, path_out)
def diff_to_file(dict1, dict2, filename, by_diff_count=False, path_out="./data/"): def diff_to_file(dict1, dict2, filename, by_diff_count=False, path_out="./data/"):
@@ -184,7 +184,7 @@ elastic = ElasticHelper(host, password, "elastic", path_base_map)
# exportTokensToFile(elastic,"mj_qa_section", "content_mj_qa_section_1.txt") # exportTokensToFile(elastic,"mj_qa_section", "content_mj_qa_section_1.txt")
exportTokensMulti(elastic,"mj_qa_section", "mj_qa_section") #exportTokensMulti(elastic,"mj_qa_section", "mj_qa_section")
diff_files_to_file("mj_qa_section1.txt", "mj_qa_section2.txt", "diff_1_2.txt") diff_files_to_file("mj_qa_section1.txt", "mj_qa_section2.txt", "diff_1_2.txt")
diff_files_to_file("mj_qa_section2.txt", "mj_qa_section1.txt", "diff_2_1.txt") diff_files_to_file("mj_qa_section2.txt", "mj_qa_section1.txt", "diff_2_1.txt")