新增:排序正序与倒序

This commit is contained in:
yystopf 2025-07-24 10:13:43 +08:00
parent 473b9e3dfd
commit ad2f42bed6
2 changed files with 3 additions and 3 deletions

View File

@ -118,8 +118,8 @@ class Issue < ApplicationRecord
LEFT JOIN users u ON assigner.assigner_id = u.id")
}
scope :ordered_by_assigner, -> {
order("CASE WHEN u.id IS NULL THEN 1 ELSE 0 END ASC")
scope :ordered_by_assigner(sort_direction), -> {
order("CASE WHEN u.id IS NULL THEN 1 ELSE 0 END #{sort_direction}")
.order("COALESCE(u.nickname, u.login) DESC")
}
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic

View File

@ -176,7 +176,7 @@ class Api::V1::Issues::ListService < ApplicationService
scope = if sort_by == 'issue_priorities.position'
scope.reorder("issue_priorities.position #{sort_direction}, issues.updated_on DESC").distinct
elsif sort_by == 'assigners'
scope.with_assigner_info.ordered_by_assigner
scope.with_assigner_info.ordered_by_assigner(sort_direction)
else
scope.reorder("#{sort_by} #{sort_direction}").distinct
end