excel codes tanghih
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
import json
|
||||
import requests
|
||||
from config_base import *
|
||||
import pyodbc
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from html import escape
|
||||
import json
|
||||
from decimal import Decimal
|
||||
import datetime
|
||||
import time
|
||||
from config_base import *
|
||||
from general_functions import *
|
||||
from text_normalizer import TextNormalizer
|
||||
from elastic_helper import ElasticHelper
|
||||
|
||||
|
||||
def moveModelToQaSectionMirror(elastic, index_name_i, index_name_o):
|
||||
try:
|
||||
body={}
|
||||
try:
|
||||
list = elastic.es_iterate_all_documents(index_name_i, body)
|
||||
except Exception as e:
|
||||
save_error(0, e)
|
||||
|
||||
dtime = myTimestamp(-100)
|
||||
count = 0
|
||||
for mentry in list:
|
||||
count += 1
|
||||
entry = mentry["source"]
|
||||
|
||||
if (count % 100) == 0 :
|
||||
print("%s -> %.2f " % (id , (count / elastic.total) if elastic.total > 0 else 0))
|
||||
|
||||
|
||||
id = entry.get("ref_id", "")
|
||||
qanon_title = entry.get("qanon_title", "")
|
||||
ts_date = entry.get("ts_date", "")
|
||||
qanon_id = entry.get("qanon_id", "")
|
||||
other_info = entry.get("other_info", {})
|
||||
model_work_tags = entry.get("work_tags", [])
|
||||
model_work_state = entry.get("work_state", [])
|
||||
model_rules = entry.get("rules", [])
|
||||
model_rules_logics = entry.get("rules_logics", [])
|
||||
model_rules_logics_triples = entry.get("rules_logics_triples", [])
|
||||
model_rules_spins = entry.get("rules_spins", [])
|
||||
model_files = entry.get("files", [])
|
||||
|
||||
user_edit = entry.get("user_edit", "")
|
||||
time_edit = entry.get("time_edit", dtime)
|
||||
user_logs = entry.get("user_log", [])
|
||||
|
||||
doc_states = ['user', 'model']
|
||||
edit_type = 'model'
|
||||
is_delete = 0
|
||||
|
||||
eid = edit_type + str(id) + '_' + str(user_edit)
|
||||
data = {
|
||||
"id" : id,
|
||||
"qanon_title" : qanon_title,
|
||||
"ts_date" : ts_date,
|
||||
"qanon_id" : qanon_id,
|
||||
"other_info" : other_info,
|
||||
"model_work_tags" : model_work_tags,
|
||||
"model_work_state" : model_work_state,
|
||||
"model_rules" : model_rules,
|
||||
"model_rules_logics" : model_rules_logics,
|
||||
"model_rules_logics_triples" : model_rules_logics_triples,
|
||||
"model_rules_spins" : model_rules_spins,
|
||||
"model_files" : model_files,
|
||||
"user_edit" : user_edit,
|
||||
"time_edit" : time_edit,
|
||||
"user_logs" : user_logs,
|
||||
"doc_states" : doc_states,
|
||||
"edit_type" : edit_type,
|
||||
"is_delete" : is_delete,
|
||||
}
|
||||
|
||||
try:
|
||||
resp = elastic.update_index_doc(False, index_name_o, eid, data)
|
||||
except Exception as e:
|
||||
print(e)
|
||||
# save_error(id, e)
|
||||
|
||||
except Exception as e:
|
||||
print("1111")
|
||||
print(e)
|
||||
|
||||
|
||||
load_dotenv(dotenv_path='config.env')
|
||||
|
||||
# host=os.getenv('HOST_160')
|
||||
# password=os.getenv('HOST_160_PASS')
|
||||
|
||||
host=os.getenv('HOST_112')
|
||||
password=os.getenv('HOST_112_PASS')
|
||||
|
||||
|
||||
path_base_map = "G:/Project2/gateway2_main/repo/_other/"
|
||||
elastic = ElasticHelper(host, password, "elastic", path_base_map)
|
||||
|
||||
|
||||
elastic.createIndex("mj_qa_section-m1", 'majles', "mj_qa_section" )
|
||||
moveModelToQaSectionMirror(elastic, "mj_model", "mj_qa_section-m1")
|
||||
Reference in New Issue
Block a user