diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 62082c792..1b219d3d7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -113,7 +113,7 @@ class UsersController < ApplicationController end def projects - scope = Projects::ListMyQuery.call(params.merge(joins: params[:joins], user_id: current_user.try(:id))) + scope = Projects::ListMyQuery.call(params.merge(category: params[:category], current_user: current_user)) @total_count = scope.size @projects = paginate(scope) diff --git a/app/models/user.rb b/app/models/user.rb index 55b3f038d..b3b614489 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -144,7 +144,7 @@ class User < ApplicationRecord has_many :apply_actions, dependent: :destroy has_many :trail_auth_apply_actions, -> { where(container_type: 'TrialAuthorization') }, class_name: 'ApplyAction' - has_many :attendances + # has_many :attendances # 兴趣 has_many :user_interests, dependent: :delete_all @@ -688,9 +688,9 @@ class User < ApplicationRecord end # 学院的url标识 - def college_identifier - Department.find_by_id(department_members.pluck(:department_id).first)&.identifier - end + # def college_identifier + # Department.find_by_id(department_members.pluck(:department_id).first)&.identifier + # end # 是否能申请试用 def can_apply_trial? diff --git a/app/queries/projects/list_my_query.rb b/app/queries/projects/list_my_query.rb index 56fcdae1d..ae9475dbc 100644 --- a/app/queries/projects/list_my_query.rb +++ b/app/queries/projects/list_my_query.rb @@ -9,24 +9,20 @@ class Projects::ListMyQuery < ApplicationQuery end def call - if params[:user_id].to_i == 2 || params[:user_id].to_i == 0 - return nil + if params[:category].blank? + projects = current_user.projects + elsif params[:category].to_s == "manage" + projects = Project.where(user_id: current_user.id) else - if params[:joins].present? - projects = Project.where.not(user_id: params[:user_id]).joins(:members).where("members.user_id = ?", params[:user_id]) - else - projects = Project.where(user_id: params[:user_id]) - end - scope = projects.includes(:members,:issues,:project_category, :project_language, owner: :user_extension).like(params[:search]) - .with_project_type(params[:project_type]) - .with_project_category(params[:category_id]) - .with_project_language(params[:language_id]) - - sort = params[:sort_by] || "updated_on" - sort_direction = params[:sort_direction] || "desc" - scope.order("projects.#{sort} #{sort_direction}") + projects = Project.where.not(user_id: current_user.id).joins(:members).where("members.user_id = ?", current_user.id) end + scope = projects.includes(:members,:issues,:project_category, :project_language, owner: :user_extension).like(params[:search]) + .with_project_type(params[:project_type]) + .with_project_category(params[:category_id]) + .with_project_language(params[:language_id]) - + sort = params[:sort_by] || "updated_on" + sort_direction = params[:sort_direction] || "desc" + scope.order("projects.#{sort} #{sort_direction}") end end diff --git a/app/views/users/homepage_info.json.jbuilder b/app/views/users/homepage_info.json.jbuilder index 112bd215c..95fab636b 100644 --- a/app/views/users/homepage_info.json.jbuilder +++ b/app/views/users/homepage_info.json.jbuilder @@ -1,22 +1,36 @@ -json.id @user.id json.name @user.full_name json.avatar_url url_to_avatar(@user) json.is_logged_user @user.logged_user? -json.experience @user.experience -json.grade @user.grade json.follow_count @user.follow_count json.fan_count @user.fan_count json.identity @user.identity -#json.brief_introduction @user.user_extension&.brief_introduction -json.authentication @user.authentication +json.brief_introduction @user.user_extension&.brief_introduction json.professional_certification @user.professional_certification json.phone_binded @user.phone_binded? json.email_binded @user.email_binded? -json.college_identifier @user.college_identifier json.followed User.current.watched?(@user) -if @user.logged_user? - #json.can_apply_trial @user.can_apply_trial? - json.attendance_signed @user.attendance_signed? - json.tomorrow_attendance_gold @user.tomorrow_attendance_gold -end +# json.id @user.id +# json.name @user.full_name +# json.avatar_url url_to_avatar(@user) +# json.is_logged_user @user.logged_user? +# json.experience @user.experience +# json.grade @user.grade +# json.follow_count @user.follow_count +# json.fan_count @user.fan_count +# json.identity @user.identity +# json.brief_introduction @user.user_extension&.brief_introduction +# json.authentication @user.authentication +# json.professional_certification @user.professional_certification +# json.phone_binded @user.phone_binded? +# json.email_binded @user.email_binded? +# json.college_identifier @user.college_identifier +# json.followed User.current.watched?(@user) +# +# if @user.logged_user? +# #json.can_apply_trial @user.can_apply_trial? +# json.attendance_signed @user.attendance_signed? +# json.tomorrow_attendance_gold @user.tomorrow_attendance_gold +# end +# +