Skip to content

Commit

Permalink
fix: filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jannchie committed Oct 24, 2019
1 parent aa49962 commit 97fe502
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion biliob_analyzer/author_fans_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __insert_event(self, delta_rate, d_daily, author, info, date):
cause = {'type': 'video'}
for each_v in videos:
# 相差一日之内
if type(each_v['datetime']) == 'str':
if type(each_v['datetime']) == str:
pass
elif (date - each_v['datetime']).days >= -1 and (date - each_v['datetime']).days <= 7:
temp_video['aid'] = each_v['aid']
Expand Down
22 changes: 22 additions & 0 deletions biliob_analyzer/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from pymongo import MongoClient
import pymysql
import redis
import os
import datetime
env_dist = os.environ
try:
client = MongoClient(env_dist.get("BILIOB_MONGO_URL"))
db = client['biliob'] # 获得数据库的句柄
except Exception:
print('{} MongoDB链接失败'.format(datetime.datetime.now()))
os.system('systemctl restart mongod')

redis_connect_string = env_dist.get("BILIOB_REDIS_CONNECTION_STRING")
redis_list = redis_connect_string.split(":")
pass_and_ip = redis_list[2].split('@')
password = pass_and_ip[0]
redis_ip = pass_and_ip[1]
redis_port = redis_list[-1]
pool = redis.ConnectionPool(password) # 实现一个连接池
redis_connection = redis.Redis(
host=redis_ip, port=redis_port, password=password)
13 changes: 13 additions & 0 deletions biliob_requests/db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from pymongo import MongoClient

settings = {
'MINGO_USER': 'jannchie',
'MONGO_PSW': '141421',
'MINGO_HOST': '127.0.0.1'
}
# 链接mongoDB
client = MongoClient(settings['MINGO_HOST'], 27017)
# 数据库登录需要帐号密码
client.admin.authenticate(settings['MINGO_USER'], settings['MONGO_PSW'])
db = client['biliob'] # 获得数据库的句柄

0 comments on commit 97fe502

Please sign in to comment.