fix error
This commit is contained in:
parent
a73850d85d
commit
35a850b038
|
@ -31,19 +31,18 @@ class BulletinFeed
|
||||||
def generate_one_cache_timeout(startdt: nil,enddt: nil,dt: nil, base_url: nil, timeout: nil)
|
def generate_one_cache_timeout(startdt: nil,enddt: nil,dt: nil, base_url: nil, timeout: nil)
|
||||||
begin
|
begin
|
||||||
if timeout.nil?
|
if timeout.nil?
|
||||||
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
|
feed_cache_content = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
|
||||||
feed_cache.content
|
|
||||||
else
|
else
|
||||||
Timeout::timeout(timeout) do
|
Timeout::timeout(timeout) do
|
||||||
feed_cache = nil
|
feed_cache_content = nil
|
||||||
thread = Thread.new do
|
thread = Thread.new do
|
||||||
feed_cache = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
|
feed_cache_content = self.generate_one_cache(startdt: startdt,enddt: enddt,dt: dt,base_url: base_url)
|
||||||
end
|
end
|
||||||
(1..(timeout.to_i+1)).each do
|
(1..(timeout.to_i+1)).each do
|
||||||
sleep(1)
|
sleep(1)
|
||||||
break if !feed_cache.nil? && !thread.alive?
|
break if !feed_cache_content.nil? && !thread.alive?
|
||||||
end
|
end
|
||||||
feed_cache.content
|
feed_cache_content
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue=> e
|
rescue=> e
|
||||||
|
@ -189,6 +188,7 @@ class BulletinFeed
|
||||||
}.to_json
|
}.to_json
|
||||||
BulletinFeedCache.where(uid: uid,start: startdt,end: enddt,date: dt).destroy
|
BulletinFeedCache.where(uid: uid,start: startdt,end: enddt,date: dt).destroy
|
||||||
feed_cache = BulletinFeedCache.create(uid: uid,content: anns,start: startdt,end: enddt,date: dt,invalid_date: invalid_date)
|
feed_cache = BulletinFeedCache.create(uid: uid,content: anns,start: startdt,end: enddt,date: dt,invalid_date: invalid_date)
|
||||||
|
feed_cache.content
|
||||||
end
|
end
|
||||||
def self.smart_convertor(text,url)
|
def self.smart_convertor(text,url)
|
||||||
doc = Nokogiri.HTML(text)
|
doc = Nokogiri.HTML(text)
|
||||||
|
|
Loading…
Reference in New Issue