DEV: Add order:title filter to experimental /filter route (#22293)

This has been requested multiple times by users so it makes sense for us
to support this as well.

See https://meta.discourse.org/t/sort-display-of-topics-alphabetically/53911
This commit is contained in:
Alan Guo Xiang Tan
2023-06-28 06:21:56 +08:00
committed by GitHub
parent d3facec7d0
commit 6c838c73e5
2 changed files with 12 additions and 1 deletions
+4 -1
View File
@@ -490,6 +490,9 @@ class TopicsFilter
"posters" => {
column: "topics.participant_count",
},
"title" => {
column: "LOWER(topics.title)",
},
"views" => {
column: "topics.views",
},
@@ -508,7 +511,7 @@ class TopicsFilter
@scope = instance_exec(&scope)
end
@scope = @scope.order(column_name => match_data[:asc] ? :asc : :desc)
@scope = @scope.order("#{column_name} #{match_data[:asc] ? "ASC" : "DESC"}")
end
end
end