add index for feed
This commit is contained in:
parent
815ee7628c
commit
12a52c2b8c
|
@ -12,6 +12,11 @@ class SiteFeedAnnc
|
|||
field :merge_with_category
|
||||
field :remote_site_url
|
||||
field :channel_title
|
||||
I18n.available_locales.each do |locale|
|
||||
index({ "all_contents_for_feed.#{locale}.is_hidden"=> -1,
|
||||
"all_contents_for_feed.#{locale}.is_top"=> -1,
|
||||
"all_contents_for_feed.#{locale}.postdate"=> -1}, { unique: false, background: true })
|
||||
end
|
||||
def get_annc(annc_uid)
|
||||
Array(self[:all_contents_for_feed]).select{|v| v['id']==annc_uid}[0] rescue {}
|
||||
end
|
||||
|
@ -164,12 +169,12 @@ class SiteFeedAnnc
|
|||
{"$match"=>match_cond},
|
||||
{"$project"=>{"data"=>"$all_contents_for_feed.#{locale}"}},
|
||||
{"$unwind"=>"$data"},
|
||||
{"$sort"=>{"data.is_hidden"=>-1,"data.is_top"=>-1,"data.postdate"=>-1}},
|
||||
{"$match"=>{"data.is_hidden"=>{"$ne"=>true},
|
||||
"data.postdate"=>{"$lte"=>Time.now},
|
||||
"data.title" => {"$gt"=>""}
|
||||
}
|
||||
},
|
||||
{"$sort"=>{"data.is_top"=>-1,"data.postdate"=>-1}}
|
||||
}
|
||||
]
|
||||
if max_len
|
||||
pipeline << {"$limit"=> max_len}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
class SiteFeedAnncCache
|
||||
include Mongoid::Document
|
||||
field :data
|
||||
field :subpart_id
|
||||
field :invalid_time
|
||||
|
||||
end
|
|
@ -34,6 +34,7 @@ module Feeds
|
|||
tmp.destroy
|
||||
end
|
||||
end
|
||||
SiteFeedAnnc.create_indexes
|
||||
end
|
||||
rescue => e
|
||||
puts ['feed_engine',e]
|
||||
|
|
Loading…
Reference in New Issue