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