f
This commit is contained in:
parent
ec42a1560d
commit
3a2f80a306
@ -9,7 +9,7 @@ import tornado.web
|
||||
import tornado.ioloop
|
||||
import tornado.web
|
||||
import json
|
||||
from myredis import myredis
|
||||
from myredis.myredis import my_redis
|
||||
import datetime
|
||||
from mysql.mmysql import MysqlBase
|
||||
from config import mysql_promotion_config
|
||||
@ -34,10 +34,10 @@ def adlist_workflow(input):
|
||||
gameid = input['gameid']
|
||||
localid = input['localtionid']
|
||||
key = f"{gameid}::{localid}"
|
||||
ids = myredis.hmgetall(key)
|
||||
ids = my_redis.hmgetall(key)
|
||||
info = []
|
||||
for id in ids:
|
||||
temp = myredis.hgetall[f"{id}::info"]
|
||||
temp = my_redis.hgetall[f"{id}::info"]
|
||||
info.append(temp)
|
||||
|
||||
return info
|
||||
@ -50,12 +50,11 @@ def getDaySeconds(time_val, incdays):
|
||||
|
||||
def send_cache_data():
|
||||
now = datetime.datetime.today().strftime("%Y-%m-%d")
|
||||
|
||||
all = []
|
||||
# 添加无天数限定的记录
|
||||
get_full_data = f"select id,name,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,companyid,locationid,gameid from " \
|
||||
"ad where begin_time={BEGIN} or end_time={END}"
|
||||
get_full_data = f"select id,name,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,companyid,locationid,gameid from ad where begin_time='{BEGIN}' or end_time='{END}'"
|
||||
full_data = mydb.query(get_full_data)
|
||||
|
||||
if full_data:
|
||||
for line in full_data:
|
||||
if line:
|
||||
@ -68,8 +67,7 @@ def send_cache_data():
|
||||
log.error("split data failed", exc_info=True)
|
||||
|
||||
# 添加有天数限定的记录
|
||||
get_data_sql = f"select id,name,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort," \
|
||||
"companyid,locationid,gameid from ad where {now}>begin_time and {now}<end_time ;"
|
||||
get_data_sql = f"select id,name,ad_num,ad_title,ad_body,ad_image,ad_url,ad_sort,companyid,locationid,gameid from ad where '{now}'>begin_time and '{now}'<end_time ;"
|
||||
|
||||
data = mydb.query(get_data_sql)
|
||||
if data:
|
||||
@ -87,19 +85,19 @@ def send_cache_data():
|
||||
if all:
|
||||
for line in all:
|
||||
key = f"{line.get('gameid', 0)}::{line.get('locationid', 0)}"
|
||||
if myredis.exists(key):
|
||||
if my_redis.exists(key):
|
||||
# 检查num是否已达到设定数值
|
||||
num = myredis.get(f"{key}:num") or 0
|
||||
num = my_redis.get(f"{key}:num") or 0
|
||||
if line['num'] != -1 and line['num'] <= num:
|
||||
# 该广告已播放达到次数,从缓存中清除
|
||||
myredis.srem(key, line['id'])
|
||||
my_redis.srem(key, line['id'])
|
||||
# 清理广告详细记录
|
||||
myredis.expire(f"{line['id']}::info", 0)
|
||||
my_redis.expire(f"{line['id']}::info", 0)
|
||||
else:
|
||||
myredis.sadd(key, line['id'])
|
||||
my_redis.sadd(key, line['id'])
|
||||
|
||||
if not myredis.exists(f"{key}::info"):
|
||||
myredis.hmset(f"{key}::info", line)
|
||||
if not my_redis.exists(f"{line['id']}::info"):
|
||||
my_redis.hmset(f"{line['id']}::info", line)
|
||||
|
||||
|
||||
class SelfCheckingHandler(tornado.web.RequestHandler):
|
||||
|
Loading…
x
Reference in New Issue
Block a user