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