search: refactor parse_query and build methods.

* Eliminate the `parse_query` method.
* Move all the metatag handling logic from the `build` method
  to `metatag_matches` and helper methods.

This is to get all the main metatag handling logic in one place, inside
`metatag_matches`, so that it's easier to add new metatags and to handle
things like negated metatags more consistently.
This commit is contained in:
evazion
2020-04-24 23:32:09 -05:00
parent 627f079e3f
commit 365e3d75af
2 changed files with 277 additions and 671 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@ class Favorite < ApplicationRecord
belongs_to :post
belongs_to :user
scope :for_user, ->(user_id) {where("user_id % 100 = #{user_id.to_i % 100} and user_id = #{user_id.to_i}")}
scope :for_user, ->(user_id) { where("favorites.user_id % 100 = ? AND favorites.user_id = ?", user_id.to_i % 100, user_id) }
scope :public_favorites, -> { where(user: User.bit_prefs_match(:enable_private_favorites, false)) }
def self.visible(user)