Commit 8a12c69a authored by lixiaofang's avatar lixiaofang

add

parent c12aab8c
......@@ -13,7 +13,9 @@ from vest.click import true_click_five, true_click_two, true_click_four, true_cl
from vest.follow import auto_follow, auto_follow_new
from vest.urge import auto_star_urge, auto_lunch_app, auto_lunch_app2, auto_urge1, auto_urge2
from vest.fix import fix_no_comment_click
from vest.reply_answer import reply_comment2, reply_comment3, answer_reply2, answer_reply3, answer_reply1
from vest.reply_answer import reply_comment2, reply_comment3, answer_reply2, answer_reply3, answer_reply1, \
answer_reply5, answer_reply7
from vest.request import get_session, auto_user_id
from vest.vest_majiauser import vest_click_reply
from vest.pictorial import principal_offline_comment1, principal_online_comment1, no_reply_principal
......@@ -117,18 +119,6 @@ class Command(BaseCommand):
if options["mvest"] == "fix_no_comment_click":
fix_no_comment_click.fix_no_comment_click()
# 二级评论
if options["mvest"] == "answer_reply1":
answer_reply1.answer_reply1()
if options["mvest"] == "answer_reply2":
answer_reply2.answer_reply2()
if options["mvest"] == "answer_reply3":
answer_reply3.answer_reply3()
if options["mvest"] == "reply_comment2":
reply_comment2.reply_comment2()
if options["mvest"] == "reply_comment3":
reply_comment3.reply_comment3()
# 获得session和use_id
if options["mvest"] == "get_login_session":
get_session.get_session()
......@@ -164,6 +154,30 @@ class Command(BaseCommand):
if options["mvest"] == "seven_days_ago_reply":
seven_days_ago_reply.serven_days_ago_comment_one()
# 修改的二级评论
# 二级评论
if options["mvest"] == "answer_reply1":
answer_reply1.answer_reply1()
if options["mvest"] == "answer_reply2":
answer_reply2.answer_reply2()
if options["mvest"] == "answer_reply3":
answer_reply3.answer_reply3()
if options["mvest"] == "answer_reply5":
answer_reply5.answer_reply5()
if options["mvest"] == "answer_reply7":
answer_reply7.answer_reply7()
if options["mvest"] == "reply_comment1":
reply_comment3.reply_comment1()
if options["mvest"] == "reply_comment2":
reply_comment2.reply_comment2()
if options["mvest"] == "reply_comment3":
reply_comment3.reply_comment3()
if options["mvest"] == "reply_comment5":
reply_comment2.reply_comment5()
if options["mvest"] == "reply_comment7":
reply_comment3.reply_comment7()
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -2,9 +2,9 @@ import pymysql
import traceback
import logging
import json
import random
from vest.request.auto_request import time_conv_minute, get_answer_data, reply_answer, set_reply_to_redis, \
reply2, logins, \
get_majia, get_majia_reply
reply2, logins, time_convs, get_majia, get_majia_reply
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
......@@ -15,71 +15,86 @@ def get_data(numtime, numtime2):
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
#
# def answer_reply1():
# try:
# logging.info("answer_reply_one")
# numtime1, numtime2, minute = time_conv_minute(5, 0)
# user_id = get_data(numtime1, numtime2)
# redis_key1 = "cybertron:set_reply_id:one"
# reply_data_comment = []
# if user_id:
# for i in user_id:
# majia_user_id = get_majia()
# logging.info("get majia_user-id:%s" % majia_user_id)
# cook = logins(majia_user_id)
# comment1, comment2 = get_answer_data()
# if cook is not None:
# response = reply_answer(cook, i[1], comment1)
# if len(response) > 1:
# data_dict = json.loads(response)
# reply_id = data_dict["data"]["id"]
# reply_user_id = data_dict["data"]["user"]["id"]
# topic_id = i[1]
# reply_data_comment.append(
# {"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
# "majia_user_id": majia_user_id})
#
# redis_client = set_reply_to_redis()
# redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
# logging.info("get eeeeeeee:%s" % str(minute - 5))
# have_reply1 = redis_client.hget(redis_key1, str(minute - 5))
# logging.info("get have_reply1:%s" % have_reply1)
# if have_reply1:
# result = json.loads(str(have_reply1, encoding="utf-8"))
# redis_client.hdel(redis_key1, str(minute - 5))
# if result:
# for item in result:
# majia_user_id = get_majia_reply(item["majia_user_id"])
# cook = logins(majia_user_id)
# reply2(cook, item["topic_id"], item["answer"], item["id"])
#
# except:
# logging_exception()
# logging.error("catch exception,main:%s" % traceback.format_exc())
def answer_reply1():
try:
logging.info("answer_reply_one")
numtime1, numtime2, minute = time_conv_minute(5, 0)
numtime1, numtime2, minute = time_convs(1, 1)
user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:one"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
logging.info("get majia_user-id:%s" % majia_user_id)
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
logging.info("get comment1:%s" % comment1)
logging.info("get comment2:%s" % comment2)
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
topic_id = i[1]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": topic_id,
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia_reply(i[0])
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
topic_id = i[1]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2,
"topic_id": topic_id,
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.hset(redis_key1, str(minute), json.dumps(reply_data_comment))
logging.info("get eeeeeeee:%s" % str(minute - 5))
have_reply1 = redis_client.hget(redis_key1, str(minute - 5))
logging.info("get have_reply1:%s" % have_reply1)
if have_reply1:
result = json.loads(str(have_reply1, encoding="utf-8"))
redis_client.hdel(redis_key1, str(minute - 5))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.set(redis_key1, json.dumps(reply_data_comment))
except:
logging_exception()
......
......@@ -2,10 +2,11 @@ import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_conv, get_answer_data, reply_answer, get_majia, \
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
......@@ -13,27 +14,10 @@ def get_data(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
print(user_id)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
......@@ -43,25 +27,28 @@ def get_data(numtime, numtime2):
def answer_reply2():
try:
logging.info("comment answer one")
numtime1, numtime2 = time_conv(27, 17)
logging.info("comment answer two")
numtime1, numtime2 = time_convs(2, 2)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:two"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
......
......@@ -2,9 +2,11 @@ import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_conv, get_answer_data, reply_answer, set_reply_to_redis, get_majia
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
......@@ -12,27 +14,10 @@ def get_data(numtime, numtime2):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time > '%s' and create_time < '%s' )" % (
numtime, numtime2))
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id = list(data)
topic_id_list = []
try:
for i in topic_id and topic_id:
cursor.execute(
"select user_id,is_shadow from user_extra where user_id =" + str(
i[0]) + " and is_online =1 and is_deleted =0")
data = cursor.fetchall()
user_id = list(data)
print(user_id)
if (user_id and user_id[0][1] == 0) or len(user_id) == 0:
topic_id_list.append(i)
logging.info("Database version : %s " % topic_id_list)
pc.close()
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
topic_id_list = list(data)
return topic_id_list
except:
......@@ -40,30 +25,33 @@ def get_data(numtime, numtime2):
return []
def answer_reply3():
def answer_reply2():
try:
logging.info("comment answer one")
numtime1, numtime2 = time_conv(45, 35)
logging.info("comment answer three")
numtime1, numtime2 = time_convs(3, 3)
user_id = get_data(numtime1, numtime2)
redis_key1 = "cybertron:set_reply_id:three"
redis_key = "cybertron:set_reply_id:three"
reply_data_comment = []
if user_id:
for i in user_id:
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key1, json.dumps(reply_data_comment))
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
......
import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def answer_reply2():
try:
logging.info("comment answer five")
numtime1, numtime2 = time_convs(5, 5)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:five"
reply_data_comment = []
if user_id:
for i in user_id:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import pymysql
import traceback
import logging
import json
from vest.request.auto_request import logins, time_convs, get_answer_data, reply_answer, get_majia, \
set_reply_to_redis
from vest.request.auto_request import host, user, db, passwd
from libs.error import logging_exception
import random
def get_data(numtime, numtime2):
try:
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
cursor.execute(
"SELECT user_id,id FROM topic WHERE is_online=1 and (create_time >= '%s' and create_time <= '%s' )" % (
numtime2, numtime))
data = cursor.fetchall()
topic_id_list = list(data)
return topic_id_list
except:
logging.error("catch exception,get_data:%s" % traceback.format_exc())
return []
def answer_reply2():
try:
logging.info("comment answer seven")
numtime1, numtime2 = time_convs(7, 7)
user_id = get_data(numtime1, numtime2)
redis_key = "cybertron:set_reply_id:seven"
reply_data_comment = []
if user_id:
for i in user_id:
random_num = random.randint(0, 2)
logging.info("get random_num:%s" % random_num)
for num in range(random_num):
majia_user_id = get_majia()
cook = logins(majia_user_id)
comment1, comment2 = get_answer_data()
if cook is not None:
response = reply_answer(cook, i[1], comment1)
if len(response) > 1:
data_dict = json.loads(response)
reply_id = data_dict["data"]["id"]
reply_user_id = data_dict["data"]["user"]["id"]
reply_data_comment.append(
{"id": reply_id, "reply_user_id": reply_user_id, "answer": comment2, "topic_id": i[1],
"majia_user_id": majia_user_id})
redis_client = set_reply_to_redis()
redis_client.set(redis_key, json.dumps(reply_data_comment))
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment1():
try:
redis_key1 = "cybertron:set_reply_id:one"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment1():
try:
redis_key1 = "cybertron:set_reply_id:five"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
import traceback
import logging
import json
from vest.request.auto_request import set_reply_to_redis, reply2, logins, get_majia_reply
from libs.error import logging_exception
def reply_comment1():
try:
redis_key1 = "cybertron:set_reply_id:seven"
redis_client = set_reply_to_redis()
have_reply1 = redis_client.get(redis_key1)
result = json.loads(str(have_reply1, encoding="utf-8"))
if result:
for item in result:
majia_user_id = get_majia_reply(item["majia_user_id"])
cook = logins(majia_user_id)
reply2(cook, item["topic_id"], item["answer"], item["id"])
redis_client.delete(redis_key1)
except:
logging_exception()
logging.error("catch exception,main:%s" % traceback.format_exc())
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