* Remove Connect
* Remove more Connect specs
* Remove a lot more Connect code
* 🚮
* It all has to go
* Explicitly add httpclient
* Update application layout
* Remove messages association from User
* Start fixing specs
* reintroduce util function and refactor references
* Remove Connect Cypress test
* Fix more specs
* Remove Connect from listings
* Ignore contact_via_connect column on listings
* Remove contact_via_connect usages
* Ignore mod_chat_channel_id on tags
* Drop Connect tables
* Remove email_connect_messages from user notification settings
* Re-add httpclient 2.8.3
This was mistakenly removed as a merge conflict
* Don't need to exclude removed chat channel file
* Remove unneeded style for chat channels
* Remove unneeded channel list prop type
* Remove chat channels index/connect-link from getPageEntries
* Re-add comment from httpclient in Gemfile
* Remove connect references from mailers
Tag Moderators no longer have a chat channel
No longer will users be notified about new messages (there won't be
any)
No longer will users be notified about channel invites (you can't
invite anyone anymore)
* Don't configure Pusher and remove PUSHER_* from .env_sample
since it's removed from gemfile, the Pusher constant will not resolve, if this is
configured in the environment variables we'll fail to boot.
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Dan Uber <dan@forem.com>
56 lines
1.5 KiB
Ruby
56 lines
1.5 KiB
Ruby
module Search
|
|
class Listing
|
|
ATTRIBUTES = %i[
|
|
id
|
|
body_markdown
|
|
bumped_at
|
|
cached_tag_list
|
|
classified_listing_category_id
|
|
expires_at
|
|
organization_id
|
|
originally_published_at
|
|
location
|
|
processed_html
|
|
published
|
|
slug
|
|
title
|
|
user_id
|
|
].freeze
|
|
private_constant :ATTRIBUTES
|
|
|
|
DEFAULT_PER_PAGE = 75
|
|
private_constant :DEFAULT_PER_PAGE
|
|
|
|
MAX_PER_PAGE = 150 # to avoid querying too many items, we set a maximum amount for a page
|
|
private_constant :MAX_PER_PAGE
|
|
|
|
def self.search_documents(category: nil, page: 0, per_page: DEFAULT_PER_PAGE, term: nil)
|
|
# NOTE: [@rhymes/atsmith813] we should eventually update the frontend
|
|
# to start from page 1
|
|
page = page.to_i + 1
|
|
per_page = [(per_page || DEFAULT_PER_PAGE).to_i, MAX_PER_PAGE].min
|
|
|
|
relation = ::Listing
|
|
.includes(:user, :organization, :listing_category)
|
|
.where(published: true)
|
|
|
|
relation = relation.where("classified_listing_categories.slug": category) if category.present?
|
|
|
|
relation = relation.search_listings(term) if term.present?
|
|
|
|
relation = relation.select(*ATTRIBUTES).order(bumped_at: :desc)
|
|
|
|
results = relation.page(page).per(per_page)
|
|
|
|
serialize(results)
|
|
end
|
|
|
|
def self.serialize(results)
|
|
Search::ListingSerializer
|
|
.new(results, is_collection: true)
|
|
.serializable_hash[:data]
|
|
.pluck(:attributes)
|
|
end
|
|
private_class_method :serialize
|
|
end
|
|
end
|