fix some error
This commit is contained in:
parent
97dd61fc52
commit
f844b3d600
|
@ -13,6 +13,12 @@ class SiteFeed
|
||||||
require 'feed_model/cache'
|
require 'feed_model/cache'
|
||||||
include FeedModel::Cache
|
include FeedModel::Cache
|
||||||
Category.send(:include,FeedModel::Cache)
|
Category.send(:include,FeedModel::Cache)
|
||||||
|
before_destroy do
|
||||||
|
tmp = SiteFeedAnnc.where(feed_id: self.id).first
|
||||||
|
if !tmp.nil?
|
||||||
|
tmp.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
scope :enabled, ->{where(:disabled => false)}
|
scope :enabled, ->{where(:disabled => false)}
|
||||||
def get_annc
|
def get_annc
|
||||||
main_directory = File.join("#{Rails.root}","public","site_feeds")
|
main_directory = File.join("#{Rails.root}","public","site_feeds")
|
||||||
|
|
|
@ -19,7 +19,7 @@ class SiteFeedAnnc
|
||||||
cat = self.category_title
|
cat = self.category_title
|
||||||
Array(self[:all_contents_for_feed]).collect do |v|
|
Array(self[:all_contents_for_feed]).collect do |v|
|
||||||
tmp = v
|
tmp = v
|
||||||
if hidden_annc.exclude?(v['id'])
|
if hidden_annc.exclude?(v['id']) && !tmp["title_translations"][locale].blank?
|
||||||
tmp['statuses'] = []
|
tmp['statuses'] = []
|
||||||
if self[:top_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
if self[:top_list].count == 0 || self[:top_list].exclude?(tmp['id'])
|
||||||
tmp[:is_top] = false
|
tmp[:is_top] = false
|
||||||
|
|
|
@ -6,18 +6,22 @@ module Feeds
|
||||||
require File.expand_path('../../../app/models/site_feed', __FILE__)
|
require File.expand_path('../../../app/models/site_feed', __FILE__)
|
||||||
require File.expand_path('../../../app/models/site_feed_annc', __FILE__)
|
require File.expand_path('../../../app/models/site_feed_annc', __FILE__)
|
||||||
if defined?(SiteFeed) && defined?(SiteFeedAnnc)
|
if defined?(SiteFeed) && defined?(SiteFeedAnnc)
|
||||||
SiteFeed.where(:disabled.ne => true).each do |site_feed|
|
SiteFeed.each do |site_feed|
|
||||||
tmp = SiteFeedAnnc.where(feed_id: site_feed.id).first
|
tmp = SiteFeedAnnc.where(feed_id: site_feed.id).first
|
||||||
if tmp.nil?
|
if site_feed.disabled != true
|
||||||
tmp = SiteFeedAnnc.new(feed_id: site_feed.id)
|
if tmp.nil?
|
||||||
|
tmp = SiteFeedAnnc.new(feed_id: site_feed.id)
|
||||||
|
end
|
||||||
|
tmp.all_contents_for_feed = site_feed.get_annc
|
||||||
|
tmp[:feed_name] = site_feed[:feed_name]
|
||||||
|
tmp.merge_with_category = site_feed.merge_with_category
|
||||||
|
tmp.channel_key = site_feed.channel_key
|
||||||
|
tmp.category_title = site_feed.category[:title] rescue {}
|
||||||
|
tmp.channel_title = site_feed.channel_title_for_cache
|
||||||
|
tmp.save
|
||||||
|
elsif !tmp.nil?
|
||||||
|
tmp.destroy
|
||||||
end
|
end
|
||||||
tmp.all_contents_for_feed = site_feed.get_annc
|
|
||||||
tmp[:feed_name] = site_feed[:feed_name]
|
|
||||||
tmp.merge_with_category = site_feed.merge_with_category
|
|
||||||
tmp.channel_key = site_feed.channel_key
|
|
||||||
tmp.category_title = site_feed.category[:title] rescue {}
|
|
||||||
tmp.channel_title = site_feed.channel_title_for_cache
|
|
||||||
tmp.save
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
|
|
Loading…
Reference in New Issue