diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-10 17:19:50 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-09-10 21:48:58 +0200 |
| commit | 793e9302311579c3c2baa3b762afd7ae38b04269 (patch) | |
| tree | 5471f0b30c45490987ae905a323b44cf55e770d5 /app/models | |
| parent | d506c3f4d2ab2cba1c5beb34a5697f11067a20c0 (diff) | |
| download | operum-793e9302311579c3c2baa3b762afd7ae38b04269.tar.gz operum-793e9302311579c3c2baa3b762afd7ae38b04269.zip | |
Update gems
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/search.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/search.rb b/app/models/search.rb index 22a282d..8a780bb 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -14,7 +14,10 @@ class Search < ApplicationRecord # This can happen as part of an empty Search.new instance. That is, it's # still invalid, but it's the object being initialized for the default # search (i.e. just show me everything). - return { things: Thing.order('rate DESC, title, created_at'), comments: [] } if body.blank? + if body.blank? + return { things: Thing.order(rate: :desc, title: :asc, created_at: :asc), + comments: [] } + end # Parse the body of the search, and return early if nothing was able to be # parsed (e.g. user wrote unknown identifiers). @@ -90,9 +93,10 @@ class Search < ApplicationRecord plain.each do |text| res[:things] = if res[:things].any? - res[:things].and(Thing.like(text:)).order('rate DESC, title, created_at') + res[:things].and(Thing.like(text:)) + .order(rate: :desc, title: :asc, created_at: :asc) else - Thing.like(text:).order('rate DESC, title, created_at') + Thing.like(text:).order(rate: :desc, title: :asc, created_at: :asc) end res[:comments] = if res[:comments].any? res[:comments].and(Comment.like(text:)).order(:created_at) |
