fix
This commit is contained in:
parent
d2788b8e1c
commit
0168cd34a1
27
ad_tasks.py
27
ad_tasks.py
@ -25,6 +25,7 @@ def get_area_by_locationid(ldid):
|
|||||||
data = mydb.query(sql)
|
data = mydb.query(sql)
|
||||||
if data:
|
if data:
|
||||||
for line in data:
|
for line in data:
|
||||||
|
pdb.set_trace()
|
||||||
area.append(line[0])
|
area.append(line[0])
|
||||||
else:
|
else:
|
||||||
log.error(f"get area from location failed!,sql={sql}")
|
log.error(f"get area from location failed!,sql={sql}")
|
||||||
@ -46,13 +47,23 @@ def split_ad_info(localtionid, line):
|
|||||||
return line
|
return line
|
||||||
|
|
||||||
|
|
||||||
|
def sadd_adkey(key, line, item):
|
||||||
|
my_redis.sadd(key, line['id'])
|
||||||
|
my_redis.expire(key, 120)
|
||||||
|
info_key = f"adinfo::{line['id']}::info"
|
||||||
|
new_line = split_ad_info(item, line)
|
||||||
|
if new_line:
|
||||||
|
my_redis.hmset(info_key, new_line)
|
||||||
|
my_redis.expire(info_key, 60 * 60)
|
||||||
|
else:
|
||||||
|
log.error(f"split adinfo about locationid failed! localtionid={item} ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def send_cache_data():
|
def send_cache_data():
|
||||||
log.info("start update cache !")
|
log.info("start update cache !")
|
||||||
now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
all = []
|
all = []
|
||||||
ad_add_list = []
|
|
||||||
get_data_sql = f"""select
|
get_data_sql = f"""select
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
@ -79,7 +90,6 @@ def send_cache_data():
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
data = mydb.query(get_data_sql)
|
data = mydb.query(get_data_sql)
|
||||||
pdb.set_trace()
|
|
||||||
if data:
|
if data:
|
||||||
for line in data:
|
for line in data:
|
||||||
if line:
|
if line:
|
||||||
@ -113,25 +123,18 @@ def send_cache_data():
|
|||||||
for line in all:
|
for line in all:
|
||||||
locationid = json.loads(line.get('locationid'))
|
locationid = json.loads(line.get('locationid'))
|
||||||
for item in locationid:
|
for item in locationid:
|
||||||
|
pdb.set_trace()
|
||||||
area = get_area_by_locationid(item)
|
area = get_area_by_locationid(item)
|
||||||
for one in area:
|
for one in area:
|
||||||
key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{one}::{item}"
|
key = f"ad::{line.get('gameid', 0)}::{line.get('channelid', 0)}::{one}::{item}"
|
||||||
if int(line['ad_num']) == 0:
|
if int(line['ad_num']) == 0:
|
||||||
ad_add_list.append(line)
|
sadd_adkey(key, line, item)
|
||||||
elif int(line['ad_num']) > 0:
|
elif int(line['ad_num']) > 0:
|
||||||
num = my_redis.get(f"adnum::{line['id']}::num")
|
num = my_redis.get(f"adnum::{line['id']}::num")
|
||||||
if not num:
|
if not num:
|
||||||
num = 0
|
num = 0
|
||||||
if int(line['ad_num']) > int(num):
|
if int(line['ad_num']) > int(num):
|
||||||
my_redis.sadd(key, line['id'])
|
sadd_adkey(key, line, item)
|
||||||
my_redis.expire(key, 120)
|
|
||||||
info_key = f"adinfo::{line['id']}::info"
|
|
||||||
new_line = split_ad_info(item, line)
|
|
||||||
if new_line:
|
|
||||||
my_redis.hmset(info_key, new_line)
|
|
||||||
my_redis.expire(info_key, 60 * 60)
|
|
||||||
else:
|
|
||||||
log.error(f"split adinfo about locationid failed! localtionid={item} ")
|
|
||||||
else:
|
else:
|
||||||
if my_redis.sismember(key, line['id']):
|
if my_redis.sismember(key, line['id']):
|
||||||
my_redis.srem(key, line['id'])
|
my_redis.srem(key, line['id'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user