search: support negated wildcards in post searches.

* Support negated wildcards in searches (e.g. "holding -holding_*")
* Raise wildcard limit to matching 25 tags regardless of user level.
* Fix wildcards potentially matching empty tags.
* Fix wildcard tags being sorted by post count only, and therefore not
  having a stable ordering when tags have equal post counts.
* Fix sidebar to calculate wildcards tags the same way the search does.
This commit is contained in:
evazion
2020-03-06 22:40:00 -06:00
parent 967d398c8e
commit 1a2c082b86
4 changed files with 45 additions and 13 deletions

View File

@@ -279,6 +279,10 @@ class Tag < ApplicationRecord
name_matches(name).or(alias_matches(name))
end
def wildcard_matches(tag, limit: 25)
nonempty.name_matches(tag).order(post_count: :desc, name: :asc).limit(limit).pluck(:name)
end
def search(params)
q = super