fix some error

This commit is contained in:
chiu 2020-04-08 20:54:44 +08:00
parent 97dd61fc52
commit f844b3d600
3 changed files with 21 additions and 11 deletions

View File

@ -13,6 +13,12 @@ class SiteFeed
require 'feed_model/cache'
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)}
def get_annc
main_directory = File.join("#{Rails.root}","public","site_feeds")

View File

@ -19,7 +19,7 @@ class SiteFeedAnnc
cat = self.category_title
Array(self[:all_contents_for_feed]).collect do |v|
tmp = v
if hidden_annc.exclude?(v['id'])
if hidden_annc.exclude?(v['id']) && !tmp["title_translations"][locale].blank?
tmp['statuses'] = []
if self[:top_list].count == 0 || self[:top_list].exclude?(tmp['id'])
tmp[:is_top] = false

View File

@ -6,8 +6,9 @@ module Feeds
require File.expand_path('../../../app/models/site_feed', __FILE__)
require File.expand_path('../../../app/models/site_feed_annc', __FILE__)
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
if site_feed.disabled != true
if tmp.nil?
tmp = SiteFeedAnnc.new(feed_id: site_feed.id)
end
@ -18,6 +19,9 @@ module Feeds
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
end
rescue => e