summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-01 14:46:04 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-01 14:46:04 +0200
commit1384756b81c719f899359efc9125e80fae8614c0 (patch)
treec8141fedeb7a03f646111177585ac05321e5f981 /app/models
parent52e260a4d7e3ac93c203bda716c37207d5f6cbbb (diff)
Allow aggregate to order by slug and paint chapters list more nicely
Diffstat (limited to 'app/models')
-rw-r--r--app/models/page.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/app/models/page.rb b/app/models/page.rb
index a66527da..8313b1d4 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -92,6 +92,11 @@ class Page < ApplicationRecord
92 .paginate(:page => page, :per_page => options[:limit]) 92 .paginate(:page => page, :per_page => options[:limit])
93 end 93 end
94 94
95 if options[:order_by] == "slug"
96 return scope.order(Arel.sql("MIN(LOWER(nodes.slug)) #{direction}"))
97 .paginate(:page => page, :per_page => options[:limit])
98 end
99
95 column = options[:order_by].to_s.sub(/\Apages\./, "") 100 column = options[:order_by].to_s.sub(/\Apages\./, "")
96 column = "id" unless %w[id published_at created_at updated_at].include?(column) 101 column = "id" unless %w[id published_at created_at updated_at].include?(column)
97 102