Commit fe070f21 authored by lixiaofang's avatar lixiaofang

add

parent 9563a254
......@@ -11,6 +11,9 @@ from libs.es import ESPerform
from libs.cache import redis_client
from trans2es.models.face_user_contrast_similar import FaceUserContrastSimilar,UserSimilarScore
from linucb.utils.register_user_tag import RegisterUserTag
from majia.tasks import auto_click
@shared_task
def write_to_es(es_type, pk_list, use_batch_query_set=False):
......@@ -32,6 +35,9 @@ def write_to_es(es_type, pk_list, use_batch_query_set=False):
use_batch_query_set=use_batch_query_set,
es=ESPerform.get_cli()
)
auto_click(pk_list)
logging.info("-----------------")
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
......@@ -7,62 +7,61 @@ import traceback
import logging
from celery import shared_task
from django.conf import settings
from majia.get_session import get_comments, click, login, reply
# from majia.get_session import host, user, passwd, db
from majia.get_session import get_comments, click, login
from majia.get_session import host, user, passwd, db
exec_count = 0
def auto_click(pk_list):
logging.info("get----------------------:%s" % pk_list)
exec_count = 0
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT id,user_id FROM topic WHERE id in " + str(
tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
data = cursor.fetchall()
topic_id_list = list(data)
logging.info("Database version : %s " % topic_id_list)
pc.close()
exec_count = 0
if topic_id_list:
logging.info("get----------------------:%s"%pk_list)
# exec_count = 0
# try:
# pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
# cursor = pc.cursor()
# cursor.execute(
# "SELECT id,user_id FROM topic WHERE id in " + str(
# tuple(pk_list)) + " and user_id in (select user_id from user_extra where is_shadow = 0)")
# data = cursor.fetchall()
# topic_id_list = list(data)
# logging.info("Database version : %s " % topic_id_list)
# pc.close()
# exec_count = 0
# if topic_id_list:
#
# def fun_timer():
# cookies = login()
# if cookies:
# click(cookies, topic_id_list[0])
#
# global timer
# global exec_count
#
# exec_count += 1
# if exec_count == 1:
# # sleep_time = random.randint(300, 540)
# sleep_time = 30
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
#
# if exec_count == 2:
# # sleep_time = random.randint(1000, 1900)
# sleep_time = 50
# timer = threading.Timer(sleep_time, fun_timer)
# timer.start()
#
# sleep_time = random.randint(300, 540)
# timer = threading.Timer(10, fun_timer) # 首次启动
# timer.start()
#
# else:
# pass
# except:
# logging.error("catch exception,main:%s" % traceback.format_exc())
def fun_timer():
cookies = login()
if cookies:
click(cookies, topic_id_list[0])
global timer
global exec_count
def auto_reply(pk_list):
exec_count += 1
if exec_count == 1:
# sleep_time = random.randint(300, 540)
sleep_time = 30
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
if exec_count == 2:
# sleep_time = random.randint(1000, 1900)
sleep_time = 50
timer = threading.Timer(sleep_time, fun_timer)
timer.start()
logging.info("get----------------------:%s"%pk_list)
sleep_time = random.randint(300, 540)
timer = threading.Timer(10, fun_timer) # 首次启动
timer.start()
else:
pass
except:
logging.error("catch exception,main:%s" % traceback.format_exc())
def auto_reply(pk_list):
logging.info("get----------------------:%s" % pk_list)
# exec_count = 0
# try:
......
......@@ -10,9 +10,9 @@ class CeleryTaskRouter(object):
"tapir-alpha": [
'injection.data_sync.tasks.write_to_es',
],
"majia-alpha": [
'majia.tasks.auto_majia_effect',
],
# "majia-alpha": [
# 'majia.tasks.auto_majia_effect',
# ],
}
# Map[TaskName, QueueName]
......
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