|
|
|
@@ -72,13 +72,13 @@ class Projects::ListMyQuery < ApplicationQuery |
|
|
|
sort = Project.column_names.include?(params[:sort_by]) ? params[:sort_by] : "updated_on" |
|
|
|
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : "desc" |
|
|
|
|
|
|
|
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) |
|
|
|
scope.distinct.order("FIELD(id, #{params[:choosed].reverse.join(",")}) desc") |
|
|
|
else |
|
|
|
if home_top_ids.present? |
|
|
|
scope.distinct.order("FIELD(id, #{home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}") |
|
|
|
if @home_top_ids.present? |
|
|
|
scope.distinct.order("FIELD(id, #{@home_top_ids.join(",")}) desc, projects.#{sort} #{sort_direction}") |
|
|
|
else |
|
|
|
scope.distinct.order("projects.#{sort} #{sort_direction}") |
|
|
|
end |
|
|
|
|