fix error

This commit is contained in:
邱博亞 2022-03-29 16:49:13 +08:00
parent d6593427f3
commit c395d4c44d
2 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,7 @@ class AnnouncementFeedsController < ApplicationController
enddt = params[:end].blank? ? nil : params[:end]
dt = params[:date].blank? ? nil : params[:date]
feed_cache = BulletinFeedCache.where(uid: uid, start: startdt, end: enddt, date: dt)
feed_cache_old = feed_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).last
feed_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy
count = feed_cache.count
if count > 1
@ -16,6 +17,7 @@ class AnnouncementFeedsController < ApplicationController
anns = ''
if feed_cache.nil?
anns = BulletinFeed.where(uid: uid).first.generate_one_cache_timeout(startdt: startdt,enddt: enddt,dt: dt,base_url: request.base_url,timeout: 20)
anns = (feed_cache_old.content rescue "") if anns.nil?
else
anns = feed_cache.content
end

View File

@ -47,7 +47,7 @@ class BulletinFeed
end
rescue=> e
puts [e,e.backtrace]
""
nil
end
end
def generate_one_cache(startdt: nil,enddt: nil,dt: nil, base_url: nil)