fix feed cache error
This commit is contained in:
parent
36ac6d8146
commit
5e7873285f
|
@ -154,6 +154,7 @@ class Admin::AnnouncementsController < OrbitAdminController
|
|||
def createfeed
|
||||
announcement_feed = BulletinFeed.new(feed_params)
|
||||
announcement_feed.save
|
||||
create_feed_cache(nil,announcement_feed)
|
||||
feeds = BulletinFeed.all.asc(:created_at)
|
||||
render :partial => "feed", :collection => feeds
|
||||
end
|
||||
|
@ -162,6 +163,7 @@ class Admin::AnnouncementsController < OrbitAdminController
|
|||
ann_feed = BulletinFeed.find(params[:id])
|
||||
ann_feed.update_attributes(feed_params)
|
||||
ann_feed.save
|
||||
create_feed_cache(nil,ann_feed)
|
||||
feeds = BulletinFeed.all.asc(:created_at)
|
||||
render :partial => "feed", :collection => feeds
|
||||
end
|
||||
|
@ -481,7 +483,8 @@ class Admin::AnnouncementsController < OrbitAdminController
|
|||
params.require(:announcement_setting).permit!
|
||||
end
|
||||
|
||||
def create_feed_cache(bulletin)
|
||||
def create_feed_cache(bulletin=nil,bulletin_feed=nil)
|
||||
if !bulletin.nil?
|
||||
BulletinFeed.where(:tag_ids.in => Array(bulletin.tag_ids).collect{|v| v.to_s}).each do |bulletin_feed|
|
||||
uid = bulletin_feed.uid
|
||||
uri = URI(request.protocol + request.host_with_port + "/xhr/announcements/feed/#{uid}.json")
|
||||
|
@ -492,5 +495,15 @@ class Admin::AnnouncementsController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
end
|
||||
elsif !bulletin_feed.nil?
|
||||
uid = bulletin_feed.uid
|
||||
uri = URI(request.protocol + request.host_with_port + "/xhr/announcements/feed/#{uid}.json")
|
||||
Thread.new do
|
||||
res_net = Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 60,read_timeout: 60) do |http|
|
||||
req = Net::HTTP::Get.new(uri)
|
||||
http.request(req)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,5 +5,7 @@ class BulletinFeed
|
|||
|
||||
field :title, as: :slug_title, type: String, localize: true
|
||||
field :tag_ids, type: Array, default: []
|
||||
|
||||
before_save do
|
||||
BulletinFeedCache.where(uid: self.uid).destroy
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@ module BulletinModel
|
|||
AnnsCache.where(parent_id:self.id).destroy
|
||||
elsif self.class == Bulletin || (self.class == Page && self.module == "announcement")
|
||||
if self.class == Bulletin
|
||||
BulletinFeedCache.where(:tag_ids.in => Array(self.tag_ids).collect{|v| v.to_s}).destroy
|
||||
BulletinFeedCache.where(:uid.in => BulletinFeed.where(:tag_ids.in => Array(self.tag_ids).collect{|v| v.to_s}).pluck(:uid)).destroy
|
||||
end
|
||||
AnnsCache.all.destroy
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue