info key刷新时间调整
This commit is contained in:
parent
ac5bff67ee
commit
2b5aff14a8
@ -46,12 +46,13 @@ class RelushADinfo(Resource):
|
||||
if areas:
|
||||
for area in areas:
|
||||
info = self._get_adinfo(adid)
|
||||
info['area'] = area
|
||||
full_info = self._update_localtion(locationid, info)
|
||||
for item in self.remove_list:
|
||||
full_info.pop(item)
|
||||
my_redis.hmset(key, full_info)
|
||||
my_redis.expire(key, self.expired)
|
||||
if info:
|
||||
info['area'] = area
|
||||
full_info = self._update_localtion(locationid, info)
|
||||
for item in self.remove_list:
|
||||
full_info.pop(item)
|
||||
my_redis.hmset(key, full_info)
|
||||
my_redis.expire(key, self.expired)
|
||||
return jsonify({'code': 200, 'message': f"reflush key locationid={locationid}!"})
|
||||
else:
|
||||
return jsonify({'code': 200, 'message': f"key not found with locationid={locationid}!"})
|
||||
@ -94,35 +95,39 @@ class RelushADinfo(Resource):
|
||||
|
||||
data = self.mydb.query(sql)
|
||||
if data:
|
||||
for line in data:
|
||||
if line:
|
||||
try:
|
||||
line = data[0]
|
||||
except Exception:
|
||||
log.error(f"split data {data} failed!", exc_info=True)
|
||||
if line:
|
||||
try:
|
||||
item = {}
|
||||
try:
|
||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], \
|
||||
item['jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], \
|
||||
item['jump_status'], item['locationid'], item['ad_property'], item['createtime'] = line
|
||||
item['createtime'] = datetime.datetime.strftime(item['createtime'], "%Y-%m-%d %H:%M:%S")
|
||||
if item.get('jump_param', "") and (item['ad_property'].find("jump_param") == -1):
|
||||
try:
|
||||
temp = {}
|
||||
temp['jump_param'] = item.get('jump_param', "")
|
||||
if not item['ad_property']:
|
||||
item['ad_property'] = {}
|
||||
if not isinstance(item.get('ad_property', {}), dict):
|
||||
if not item.get('ad_property', {}):
|
||||
item['ad_property'] = {}.update(temp)
|
||||
else:
|
||||
item['ad_property'] = json.loads(
|
||||
item.get('ad_property', {}).replace("‘", '"').replace("’", '"'))
|
||||
item['ad_property'].update(temp)
|
||||
item['ad_property'] = json.dumps(item['ad_property'])
|
||||
item['id'], item['name'], item['ad_num'], item['ad_title'], item['ad_body'], item['ad_image'], item[
|
||||
'jump_param'], item['ad_sort'], item['companyid'], item['gameid'], item['channelid'], item[
|
||||
'jump_status'], item['locationid'], item['ad_property'], item['createtime'] = line
|
||||
item['createtime'] = datetime.datetime.strftime(item['createtime'], "%Y-%m-%d %H:%M:%S")
|
||||
if item.get('jump_param', "") and (item['ad_property'].find("jump_param") == -1):
|
||||
temp = {}
|
||||
temp['jump_param'] = item.get('jump_param', "")
|
||||
if not item['ad_property']:
|
||||
item['ad_property'] = {}
|
||||
if not isinstance(item.get('ad_property', {}), dict):
|
||||
if not item.get('ad_property', {}):
|
||||
item['ad_property'] = {}.update(temp)
|
||||
else:
|
||||
item['ad_property'] = json.loads(
|
||||
item.get('ad_property', {}).replace("‘", '"').replace("’", '"'))
|
||||
item['ad_property'].update(temp)
|
||||
item['ad_property'] = json.dumps(item['ad_property'])
|
||||
return item
|
||||
except Exception:
|
||||
log.error(f"write {item}", exc_info=True)
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
else:
|
||||
return None
|
||||
|
||||
except Exception:
|
||||
log.error(f"write {item}", exc_info=True)
|
||||
all.append(item)
|
||||
except Exception:
|
||||
log.error("split data failed", exc_info=True)
|
||||
return all
|
||||
|
||||
|
||||
def _update_localtion(self, id, line):
|
||||
|
Loading…
x
Reference in New Issue
Block a user