This commit is contained in:
yystopf 2024-07-17 15:51:15 +08:00
parent 6dda125a1c
commit 8177606f81
1 changed files with 2 additions and 2 deletions

View File

@ -75,10 +75,10 @@ class Projects::ListMyQuery < ApplicationQuery
@home_top_ids = scope.joins(:home_top_settings).where(home_top_settings: {user_id: user.id}).order("home_top_settings.created_at asc").pluck(:id) @home_top_ids = scope.joins(:home_top_settings).where(home_top_settings: {user_id: user.id}).order("home_top_settings.created_at asc").pluck(:id)
if params[:choosed].present? && params[:choosed].is_a?(Array) if params[:choosed].present? && params[:choosed].is_a?(Array)
scope = scope.distinct.order("FIELD(id, #{params[:choosed].reverse.join(",")}) desc") scope = scope.distinct.order("FIELD(projects.id, #{params[:choosed].reverse.join(",")}) desc")
else else
if @home_top_ids.present? if @home_top_ids.present?
scope = scope.distinct.order("FIELD(id, #{@home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}") scope = scope.distinct.order("FIELD(projects.id, #{@home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}")
else else
scope = scope.distinct.order("projects.#{sort} #{sort_direction}") scope = scope.distinct.order("projects.#{sort} #{sort_direction}")
end end