@@ -2,7 +2,7 @@ class Bookmark < ApplicationRecord
22 belongs_to :user
33 belongs_to :bookmarkable , polymorphic : true
44
5- BOOKMARKABLE_MODELS = %w[ CommunityNews Event Organization Person Report Resource Story StoryIdea
5+ BOOKMARKABLE_MODELS = %w[ CommunityNews Event Faq Organization Person Report Resource Story StoryIdea
66 Tutorial Workshop WorkshopIdea WorkshopLog WorkshopVariation WorkshopVariationIdea ] . freeze
77
88 DROPDOWN_MODELS = ( BOOKMARKABLE_MODELS - %w[ Report ] ) . freeze
@@ -62,6 +62,7 @@ def self.sort_by_title
6262 bookmarks = self . joins ( <<~SQL )
6363 LEFT JOIN community_news AS st_cn ON st_cn.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'CommunityNews'
6464 LEFT JOIN events AS st_ev ON st_ev.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Event'
65+ LEFT JOIN faqs AS st_faq ON st_faq.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Faq'
6566 LEFT JOIN organizations AS st_org ON st_org.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Organization'
6667 LEFT JOIN people AS st_ppl ON st_ppl.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Person'
6768 LEFT JOIN resources AS st_res ON st_res.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Resource'
@@ -80,6 +81,7 @@ def self.sort_by_title
8081 COALESCE(
8182 st_cn.title,
8283 st_ev.title,
84+ st_faq.question,
8385 CONCAT(st_ppl.first_name, ' ', st_ppl.last_name),
8486 st_org.name,
8587 st_rpt.type,
@@ -106,6 +108,7 @@ def self.title(title)
106108 bookmarks = bookmarks . joins ( <<~SQL )
107109 LEFT JOIN community_news ON community_news.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'CommunityNews'
108110 LEFT JOIN events ON events.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Event'
111+ LEFT JOIN faqs ON faqs.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Faq'
109112 LEFT JOIN organizations ON organizations.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Organization'
110113 LEFT JOIN people ON people.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Person'
111114 LEFT JOIN resources ON resources.id = bookmarks.bookmarkable_id AND bookmarks.bookmarkable_type = 'Resource'
@@ -121,7 +124,7 @@ def self.title(title)
121124 SQL
122125
123126 bookmarks . where (
124- "community_news.title LIKE :title OR events.title LIKE :title OR people.first_name LIKE :title OR
127+ "community_news.title LIKE :title OR events.title LIKE :title OR faqs.question LIKE :title OR people.first_name LIKE :title OR
125128 people.last_name LIKE :title OR organizations.name LIKE :title OR resources.title LIKE :title OR
126129 reports.type LIKE :title OR
127130 stories.title LIKE :title OR workshops.title LIKE :title OR workshop_ideas.title LIKE :title OR
0 commit comments