Commit 37a2c560 authored by lixiaofang's avatar lixiaofang

Merge branch 'test'

parents b5932bf8 2aaf08e2
__pycache__/
*.py[c|o]
.gm_rpcd.log/
.idea
settings_local.py
.gm_rpcd.develop_conf.xml
celerybeat-schedule
celerybeat-schedule.db
celerybeat.pid
_build/
.env/
.vscode/
request.log
env/
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
This diff is collapsed.
<component name="ProjectDictionaryState">
<dictionary name="lxrent" />
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7 (gaia_env)" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/vest.iml" filepath="$PROJECT_DIR$/.idea/vest.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
This diff is collapsed.
......@@ -7,6 +7,8 @@
<element value="vest"/>
</config>
<config name="initializer_list">
<element value="vest.django_init"/>
<element value="moment.views.irrigation"/>
</config>
</gm_rpcd_config>
......@@ -61,7 +61,6 @@ def auto_click_user(card_info, after_day=False):
after_day=after_day,
card_info=card_info,
repeat_time=repeat_time)
logging.info("get get_time and time_region:%s" % get_time)
if len(get_time) > 0 and time_region != 3:
###拿到下发时间后根据下发的时间个数去拿对应个数的马甲账号
......@@ -83,7 +82,6 @@ def auto_click_user(card_info, after_day=False):
else: # 代表还有push好的时间没有下发完成 需要继续使用这些
logging.info("get--------click--------------card_info:%s" % card_info)
current_user_id = card_info["current_user_id"]
card_info["all_follow_id"].remove(current_user_id)
current_push_time = card_info['current_push_time']
......
......@@ -69,7 +69,6 @@ def auto_comment_user(card_info, after_day=False):
after_day=after_day,
card_info=card_info,
repeat_time=repeat_time)
logging.info("get get_time and time_region:%s" % get_time)
if len(get_time) > 0 and time_region != 3:
###拿到下发时间后根据下发的时间个数去拿对应个数的马甲账号
all_content = get_vest_userid_and_comment(need_comment_num=len(get_time),
......@@ -95,10 +94,8 @@ def auto_comment_user(card_info, after_day=False):
break
repeat_time += 1
logging.info("get have_get_after__time:%s" % card_info)
logging.info("get comment_have_get_after__time:%s" % card_info)
else: # 代表还有push好的时间没有下发完成 需要继续使用这些
logging.info("get-------comment---------------card_info:%s" % card_info)
current_user_id = card_info["current_user_id"]
card_info["all_follow_id"].remove(current_user_id)
current_push_time = card_info['current_push_time']
......
......@@ -61,7 +61,6 @@ def auto_follow_user(card_info, after_day=False):
after_day=after_day,
card_info=card_info,
repeat_time=repeat_time)
logging.info("get get_time and time_region:%s" % get_time)
if len(get_time) > 0 and time_region != 3:
......@@ -101,8 +100,6 @@ def auto_follow_user(card_info, after_day=False):
save_data_to_kafka(card_info) # 存储数据
logging.info("get-----follow----card_info:%s" % card_info)
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vest.settings')
django.setup()
......@@ -26,13 +26,13 @@ def kafka_consum(topic_name=None):
try:
while True:
msg_dict = consumser_obj.poll(timeout_ms=100, max_records=10)
msg_dict = consumser_obj.poll(timeout_ms=100, max_records=50)
for msg_key in msg_dict:
consume_msg = msg_dict[msg_key]
for msg in consume_msg:
card_info = json.loads(msg.value)
if card_info['card_type'] == "answer":
if card_info['card_type'] == "auto_vest123":
logging.info("+++++++++++++++++++++++++新的数据进来了+++++++++++++++++++++++")
logging.info("get card_info:%s" % card_info)
# 代表当天数据
......@@ -41,7 +41,6 @@ def kafka_consum(topic_name=None):
nowtime = datetime.datetime.now()
push_time_date = datetime.datetime.strptime(current_push_time, '%Y-%m-%d %H:%M:%S')
if push_time_date <= nowtime: # push_time已经到时间了 需要去下发
logging.info("get push_time_date:%s" % push_time_date)
# 判断如果当前的push_time 和当前的创建时间一样 需要给push_time下发真的push时间
if current_push_time == create_time:
if card_info['action_type'] == "comment":
......
......@@ -7,8 +7,8 @@ import jieba.analyse
class GetContentKeyWords(object):
def __init__(self):
self.jeiba = jieba
self.tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "埋线提升kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
"牙齿kyc", "抗衰紧致kyc", "胸部kyc"]
self.tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
"牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
self.star_list = []
self.synonym_tag_list = []
self.tags = ""
......
......@@ -9,16 +9,28 @@ from django.conf import settings
import datetime
import time
import logging
from libs.error import logging_exception
@bind('vest/moment/vest_irrigation')
def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time="", content_level=0, tag_names=[]):
try:
producer = KafkaProducer(bootstrap_servers=[settings.KAFKA_BROKER_LIST])
logging.info("-----------------------------------------------")
topic = settings.KAFKA_TOPIC_NAME
tag_list = ["瘦脸针kyc", "双眼皮kyc", "水光针kyc", "玻尿酸kyc", "吸脂kyc", "祛痘kyc", "鼻综合kyc", "光子嫩肤kyc", "没有想法kyc",
"牙齿kyc", "抗衰紧致kyc", "胸部kyc", "果酸换肤kyc", "祛斑kyc", "美白针kyc", "瘦腿针kyc"]
flag = False
if len(tag_names) > 0:
for i in tag_names:
if i in tag_list:
flag = True
if flag == True:
comment_msg_dict = {
"card_id": card_id,
"card_type": card_type,
"card_type": "auto_vest123",
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -27,11 +39,12 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
'action_type': 'comment'
}
logging.info("get comment_msg_dict:%s" % comment_msg_dict)
producer.send(topic, json.dumps(comment_msg_dict).encode())
follow_msg_dict = {
"card_id": card_id,
"card_type": card_type,
"card_type": "auto_vest123",
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -45,7 +58,7 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
click_msg_dict = {
"card_id": card_id,
"card_type": card_type,
"card_type": "auto_vest123",
"create_time": create_time,
"content_level": content_level,
"tag_names": tag_names,
......@@ -59,4 +72,5 @@ def vest_irrigation(card_id=0, card_type=None, card_user_id=None, create_time=""
producer.close()
except:
logging_exception()
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -157,18 +157,15 @@ def get_content_time_by_create_time(create_time="", content_level=0, action_type
num_days += repeat_time
content_day_need_add_one_day = True
# 创建时间切换成分钟数便于比较
logging.info("get num_days:%s" % num_days)
# mins = divmod(num, min)[0]
##根据转换后的分钟数进行比较
##转化成分数后进行一层一层的比较
if num_days == 0:
print("当天")
get_time = randomDate(create_time=createt, action_type=action_type)
time_region = 0
return get_time, time_region
elif num_days >= 1 and num_days <= 6:
print("1-6天的")
get_time = get_one_six_days_random_time(content_level=content_level, num_days=num_days,
action_type=action_type,
content_day_need_add_one_day=content_day_need_add_one_day)
......@@ -176,7 +173,6 @@ def get_content_time_by_create_time(create_time="", content_level=0, action_type
return get_time, time_region
elif num_days > 6 and num_days <= 365:
print("6天后的")
get_time = get_ten_last_days_random_time(num_days=num_days, content_level=content_level,
content_day_need_add_one_day=content_day_need_add_one_day)
time_region = 2
......@@ -184,7 +180,6 @@ def get_content_time_by_create_time(create_time="", content_level=0, action_type
else:
##需要删掉kafka的数据不再进行下发
print("所有下发结束")
return [], 3
except:
......@@ -213,44 +208,31 @@ def get_click_follow_time_by_create_time(create_time="", content_level=0, action
##转化成分数后进行一层一层的比较
if num_days == 0:
print("当天")
get_time = randomDate(create_time=createt, action_type=action_type)
logging.info("拿到当天的时间 get get_time:%s" % get_time)
return get_time, 0
elif num_days == 1:
print("1天的")
get_time = get_one_six_days_random_time(num_days=num_days, action_type=action_type,
content_level=content_level,
content_day_need_add_one_day=content_day_need_add_one_day)
logging.info("1天的 get get_time:%s" % get_time)
return get_time, 1
elif num_days > 1 and num_days <= 15:
print("2-15天后的")
get_time = get_one_six_days_random_time(num_days=num_days, action_type=action_type,
content_level=content_level,
content_day_need_add_one_day=content_day_need_add_one_day)
logging.info("2-15天后的的时间 get get_time:%s" % get_time)
return get_time, 2
elif num_days > 15 and num_days <= 365:
##需要删掉kafka的数据不再进行下发
print("15天后的")
get_time = get_ten_last_days_random_time(num_days=num_days, action_type=action_type,
content_level=content_level,
content_day_need_add_one_day=content_day_need_add_one_day)
logging.info("拿到15天后的时间 get get_time:%s" % get_time)
return get_time, 4
else:
print("所有下发结束")
return [], 3
except:
......@@ -326,8 +308,6 @@ def get_vest_userid_and_comment(need_comment_num=0, tag_names=[], card_id=0):
else:
content = None
logging.info("get content:%s" % content)
return content
except:
......
This diff is collapsed.
This diff is collapsed.
celery==4.2.1
Django==1.8
Django==1.9
elasticsearch==6.3.1
git+ssh://git@git.wanmeizhensuo.com/backend/gm-config.git@v0.1.3
git+ssh://git@git.wanmeizhensuo.com/backend/gm-logging.git@v0.8.4
......@@ -9,7 +9,7 @@ git+ssh://git@git.wanmeizhensuo.com/system/gm-tracer.git@v0.1.2
git+ssh://git@git.wanmeizhensuo.com/backend/gm-types.git@master
git+ssh://git@git.wanmeizhensuo.com/backend/gm-upload.git@master
git+ssh://git@git.wanmeizhensuo.com/system/kafka-python.git@master
PyMySQL==0.7.10
PyMySQL==0.9.2
python-dateutil==1.5
python-json-logger==0.1.11
raven==5.25.0
......
import pymysql
pymysql.install_as_MySQLdb()
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vest.settings')
django.setup()
......@@ -27,6 +27,7 @@ SECRET_KEY = '18i6m2l99g9ev46#)j4d)h!_zn8co-52veo69spj*1&v%x-^n0'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ROOT_URLCONF = 'vest.urls'
ALLOWED_HOSTS = []
# Application definition
......@@ -77,12 +78,20 @@ WSGI_APPLICATION = 'vest.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql', # 设置为mysql数据库
# 'NAME': 'mimas_test',
# 'USER': 'work',
# 'PASSWORD': 'Gengmei1',
# 'HOST': 'bj-cdb-6slgqwlc.sql.tencentcdb.com',
# 'PORT': '62120',
# 'OPTIONS': {
# "init_command": "SET foreign_key_checks = 0;",
# "charset": "utf8mb4", # 为了支持emoji表情
# }
# }
# }
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
......
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