Added tag and hashtag filtering functionality to feeds
This commit is contained in:
parent
f88ff91d4f
commit
1ed4665e29
|
|
@ -50,7 +50,7 @@ module AnnouncementsHelper
|
|||
"img_description" => desc
|
||||
}
|
||||
end
|
||||
def get_feed_annc(type,site_source,locale,categories=nil,max_len=nil,sort_maps=nil,extra_match_cond=nil)
|
||||
def get_feed_annc(type,site_source,locale,categories=nil,max_len=nil,sort_maps=nil,extra_match_cond=nil,tags=nil,hashtags=nil)
|
||||
ma_key = 'announcement'
|
||||
if categories.nil?
|
||||
if type == "index"
|
||||
|
|
@ -70,11 +70,13 @@ module AnnouncementsHelper
|
|||
type=='widget',
|
||||
max_len,
|
||||
sort_maps,
|
||||
extra_match_cond
|
||||
extra_match_cond,
|
||||
tags,
|
||||
hashtags
|
||||
)
|
||||
data
|
||||
end
|
||||
def get_feed_announcements(type,site_source=nil,categories=nil,max_len=nil,extra_match_cond=[])
|
||||
def get_feed_announcements(type,site_source=nil,categories=nil,max_len=nil,extra_match_cond=[],tags=nil,orbithashtag=nil)
|
||||
locale = OrbitHelper.get_site_locale.to_s
|
||||
feeds = []
|
||||
feeds_count = 0
|
||||
|
|
@ -96,7 +98,7 @@ module AnnouncementsHelper
|
|||
if !extra_match_cond.empty?
|
||||
match_cond["$and"] += extra_match_cond
|
||||
end
|
||||
feeds, feeds_count = get_feed_annc(type,site_source,locale,categories,max_len,sort_maps,match_cond)
|
||||
feeds, feeds_count = get_feed_annc(type,site_source,locale,categories,max_len,sort_maps,match_cond,tags,orbithashtag)
|
||||
end
|
||||
return feeds, feeds_count
|
||||
end
|
||||
|
|
@ -124,6 +126,7 @@ module AnnouncementsHelper
|
|||
announcements = []
|
||||
feeds_count = 0
|
||||
extra_match_cond = []
|
||||
orbithashtag = params["orbithashtag"]
|
||||
if !params[:keywords].blank?
|
||||
extra_match_cond << {
|
||||
"title_plain_text" => OrbitHelper.get_keyword_regex(params[:keywords])
|
||||
|
|
@ -143,9 +146,20 @@ module AnnouncementsHelper
|
|||
end
|
||||
if !params["source"].present?
|
||||
if params["orbithashtag"].present?
|
||||
announcements = Bulletin.can_display_and_sorted
|
||||
.filter_by_categories(categories, false).filter_by_hashtag(OrbitHelper.page_hashtag_id).filter_by_tags(tags)
|
||||
.where(:title.nin => ["",nil])
|
||||
target_hashtag = Hashtag.where(name: params["orbithashtag"]).first
|
||||
if target_hashtag
|
||||
b_ids = Hashtagging.where(
|
||||
hashtag_id: target_hashtag.id,
|
||||
hashtaggable_type: "Bulletin"
|
||||
).pluck(:hashtaggable_id)
|
||||
announcements = Bulletin.can_display_and_sorted
|
||||
.filter_by_categories(categories, false)
|
||||
.filter_by_tags(tags)
|
||||
.where(:id.in => b_ids)
|
||||
.where(:title.nin => ["", nil])
|
||||
else
|
||||
announcements = Bulletin.none
|
||||
end
|
||||
else
|
||||
announcements = Bulletin.can_display_and_sorted
|
||||
.filter_by_categories(categories, false).filter_by_tags(tags)
|
||||
|
|
@ -162,10 +176,10 @@ module AnnouncementsHelper
|
|||
end
|
||||
end
|
||||
if !(defined? SiteFeed).nil? && @type != "show_widget"
|
||||
feeds_anns, feeds_count = get_feed_announcements("index",nil,categories,page_number*page_data_count,extra_match_cond)
|
||||
feeds_anns, feeds_count = get_feed_announcements("index",nil,categories,page_number*page_data_count,extra_match_cond,tags,orbithashtag)
|
||||
end
|
||||
elsif @type != "show_widget"
|
||||
feeds_anns, feeds_count = get_feed_announcements("index",params["source"],categories,page_number*page_data_count,extra_match_cond)
|
||||
feeds_anns, feeds_count = get_feed_announcements("index",params["source"],categories,page_number*page_data_count,extra_match_cond,tags,orbithashtag)
|
||||
end
|
||||
if !feeds_anns.blank?
|
||||
all_filter = sort_announcements(announcements + feeds_anns)
|
||||
|
|
|
|||
Loading…
Reference in New Issue