新增:列表页新增only_watched参数
This commit is contained in:
parent
30437d828c
commit
13e2738fb5
|
@ -29,6 +29,8 @@ class Projects::ListMyQuery < ApplicationQuery
|
|||
projects = projects.where(user_id: user.id)
|
||||
elsif params[:category].to_s == "watched" #我关注的
|
||||
projects = projects.where.not(user_id: user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id})
|
||||
elsif params[:category].to_s == 'only_watched'
|
||||
projects = projects.joins(:watchers).where(watchers: {watchable_type: "Project", user_id: user.id})
|
||||
elsif params[:category].to_s == "forked" #我fork的
|
||||
fork_ids = user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
|
||||
projects = projects.where(id: fork_ids)
|
||||
|
|
|
@ -53,6 +53,8 @@ class Api::V1::Users::Projects::ListService < ApplicationService
|
|||
projects = Project.from("( #{normal_projects} UNION #{org_projects} ) AS projects").distinct
|
||||
when 'watched'
|
||||
projects = projects.where.not(user_id: observe_user.id).joins(:watchers).where(watchers: {watchable_type: "Project", user_id: observe_user.id})
|
||||
when 'only_watched'
|
||||
projects = projects.where.joins(:watchers).where(watchers: {watchable_type: "Project", user_id: observe_user.id})
|
||||
when 'forked'
|
||||
fork_ids = observe_user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
|
||||
projects = projects.where(id: fork_ids)
|
||||
|
|
Loading…
Reference in New Issue