Commit 1122f905 authored by 吴升宇's avatar 吴升宇

fix 5m_by_follow

parent 13c6e56e
import pymysql
import traceback
import logging
from vest.request.auto_request import login, follow, time_conv
from vest.request.auto_request import login, follow, time_conv_minute
from vest.request.auto_request import host, user, db, passwd
from vest.data.majia_user_ids import majia_user_ids_list, majia_user_ids_dict
from vest.data.majia_user_ids import majia_user_ids_dict
from libs.error import logging_exception
def get_user_id(numtime):
pc = pymysql.connect(host=host, user=user, passwd=passwd, db=db, port=3306)
cursor = pc.cursor()
majia_user_ids_tuple = tuple(majia_user_ids_list)
cursor.execute(
"SELECT user_id, follow_id FROM user_follow WHERE create_time > '%s' and follow_id in %s " % (numtime, str(majia_user_ids_tuple))
"SELECT f.user_id, f.follow_id FROM user_follow f left join user_extra on f.follow_id = e.user_id "
"WHERE f.create_time >= '%s' and e.is_shadow = 1 " % numtime
)
data_comment = cursor.fetchall()
return data_comment and [i for i in data_comment] or []
......@@ -21,7 +21,7 @@ def get_user_id(numtime):
def auto_follow_per_5m_by_followed():
# 如果马甲被用户关注,马甲即反向关注用户, 被关注5分钟后
try:
numtime1, numtime2 = time_conv(1, 5)
numtime1, numtime2, c = time_conv_minute(1, 5)
users = get_user_id(numtime2)
try:
for user in users and users:
......
......@@ -119,15 +119,16 @@ def get_commnet_id(numtime, numtime2):
def time_conv_hour(minutest, minutest2):
def time_conv_minute(minutest, minutest2):
try:
now = datetime.datetime.now()
yes_time = now - datetime.timedelta(hours=minutest)
yes_time2 = now - datetime.timedelta(hours=minutest2)
return yes_time, yes_time2
minute = datetime.datetime.now().minute
yes_time = now - datetime.timedelta(minutes=minutest)
yes_time2 = now - datetime.timedelta(minutes=minutest2)
return yes_time, yes_time2, minute
except:
return None
a, b = time_conv_hour(0, 2)
a, b, c = time_conv_minute(0, 5)
print(a, b)
\ No newline at end of file
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