Commit b2b82d2e authored by lixiaofang's avatar lixiaofang

add

parent 7fb0a657
...@@ -43,9 +43,9 @@ def write_to_es(es_type, pk_list, use_batch_query_set=False): ...@@ -43,9 +43,9 @@ def write_to_es(es_type, pk_list, use_batch_query_set=False):
# es=ESPerform.get_cli() # es=ESPerform.get_cli()
# ) # )
if es_type == 'topic': # if es_type == 'topic':
auto_click(pk_list) auto_click(pk_list)
auto_reply(pk_list) auto_reply(pk_list)
except: except:
...@@ -127,14 +127,20 @@ def auto_click(pk_list): ...@@ -127,14 +127,20 @@ def auto_click(pk_list):
cursor = pc.cursor() cursor = pc.cursor()
topic_id_list = [] topic_id_list = []
if len(pk_list) > 0: if len(pk_list) > 0:
cursor.execute( if len(pk_list) == 1:
"SELECT id FROM topic WHERE id in " + str( # and create_time LIKE '%%%%%s%%%%'% yes_time_str cursor.execute(
tuple( "SELECT id FROM topic WHERE id = " + str(
pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)") pk_list[0]) + " and user_id in (select user_id from user_extra where is_shadow = 1)")
else:
cursor.execute(
"SELECT id FROM topic WHERE id in " + str( # and create_time LIKE '%%%%%s%%%%'% yes_time_str
tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 1)")
data = cursor.fetchall() data = cursor.fetchall()
topic_id_list = list(data) topic_id_list = list(data)
logging.info("Database version : %s " % topic_id_list) logging.info("Database version : %s " % topic_id_list)
pc.close() pc.close()
if topic_id_list: if topic_id_list:
try: try:
def fun_timer(): def fun_timer():
...@@ -185,10 +191,15 @@ def auto_reply(pk_list): ...@@ -185,10 +191,15 @@ def auto_reply(pk_list):
topic_id_list = [] topic_id_list = []
try: try:
if len(pk_list) > 0: if len(pk_list) > 0:
cursor.execute( if len(pk_list) == 1:
"SELECT id,user_id FROM topic WHERE id in " + str(tuple( cursor.execute(
pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0) and create_time LIKE '%%%%%s%%%%' " % ( "SELECT id FROM topic WHERE id = " + str(tuple( # and create_time LIKE '%%%%%s%%%%'
yes_time_str)) pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0) ")
else:
cursor.execute(
"SELECT id FROM topic WHERE id in " + str(tuple( # and create_time LIKE '%%%%%s%%%%'
pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0) ")
data = cursor.fetchall() data = cursor.fetchall()
topic_id_list = list(data) topic_id_list = list(data)
...@@ -204,7 +215,7 @@ def auto_reply(pk_list): ...@@ -204,7 +215,7 @@ def auto_reply(pk_list):
if cookies: if cookies:
comment_content = get_comments() comment_content = get_comments()
comment = comment_content[0] comment = comment_content[0]
reply(cookies, topic_id_list[0], comment) reply(cookies, topic_id_list[0][0], comment)
global timer global timer
global exec_count global exec_count
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment