Fix limit error.

This commit is contained in:
BoHung Chiu 2021-11-10 15:27:06 +08:00
parent c5a96e8917
commit e3ab735f43
1 changed files with 35 additions and 31 deletions

View File

@ -159,6 +159,8 @@ class SiteFeedAnnc
end
def self.get_feed_cache(channel_key,merge_with_category=nil,site_source=nil,locale=I18n.locale.to_s,is_widget=false,max_len=nil)
max_len = ((max_len.to_i < 0 rescue true) ? 0 : max_len.to_i)
if max_len > 0
match_cond = {"channel_key"=>channel_key}
if !merge_with_category.blank? && merge_with_category.exclude?('all')
match_cond["merge_with_category"] = {"$in"=>merge_with_category}
@ -177,7 +179,6 @@ class SiteFeedAnnc
}
}
]
max_len = 0 if (max_len.to_i < 0 rescue true)
if max_len
pipeline << {"$limit"=> max_len}
end
@ -192,6 +193,9 @@ class SiteFeedAnnc
end
tmp
end
else
[]
end
end
def all_contents_for_feed(site_source=nil,locale=I18n.locale.to_s,is_widget=false)