|
@@ -69,8 +69,10 @@ class WeatherView(View):
|
|
|
humidity = weather_list[0]['humidity']
|
|
|
for item in weather_list:
|
|
|
temp_time = CommonService.str_to_timestamp(item['date'] + ' ' + item['hour'] + ':00:00')
|
|
|
- redis_obj.set_ex_data('city_id_{}_{}_weather'.format(city_id, temp_time),
|
|
|
- '{}/{}'.format(item['temp'], item['humidity']), 86400)
|
|
|
+ result = redis_obj.set_ex_data('city_id_{}_{}_weather'.format(city_id, temp_time),
|
|
|
+ '{}/{}'.format(item['temp'], item['humidity']), 86400)
|
|
|
+ if not result:
|
|
|
+ LOGGER.info('写入天气失败:{}'.format(item))
|
|
|
if not all([temp, humidity]):
|
|
|
return response.json(10, '获取天气失败')
|
|
|
return response.json(0, {'temp': temp, 'humidity': humidity})
|