mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Use hash arguments to order when possible (Rails 7.2) (#32915)
This commit is contained in:
@@ -61,7 +61,7 @@ class Tag < ApplicationRecord
|
||||
scope :recently_used, lambda { |account|
|
||||
joins(:statuses)
|
||||
.where(statuses: { id: account.statuses.select(:id).limit(RECENT_STATUS_LIMIT) })
|
||||
.group(:id).order(Arel.sql('count(*) desc'))
|
||||
.group(:id).order(Arel.star.count.desc)
|
||||
}
|
||||
scope :matches_name, ->(term) { where(arel_table[:name].lower.matches(arel_table.lower("#{sanitize_sql_like(Tag.normalize(term))}%"), nil, true)) } # Search with case-sensitive to use B-tree index
|
||||
|
||||
@@ -127,7 +127,7 @@ class Tag < ApplicationRecord
|
||||
query = query.merge(Tag.listable) if options[:exclude_unlistable]
|
||||
query = query.merge(matching_name(stripped_term).or(reviewed)) if options[:exclude_unreviewed]
|
||||
|
||||
query.order(Arel.sql('length(name) ASC, name ASC'))
|
||||
query.order(Arel.sql('LENGTH(name)').asc, name: :asc)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user