summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-20 09:51:00 +0000
committerRémy Coutable <remy@rymai.me>2017-09-20 09:51:00 +0000
commitd247841b48c6ad5b3891671e30bedeb409bfad30 (patch)
tree1b90239c8d63574be3df6965f7fcc544fd749221 /app
parent36dc65d5ca34234faf8e79106ed081a28659d899 (diff)
parentc9d40927f877a9d4896edcd94c8525ba8eba3ffd (diff)
downloadgitlab-ce-d247841b48c6ad5b3891671e30bedeb409bfad30.tar.gz
Merge branch '20049-projects-api-forks' into 'master'
Resolve "make project data via API report forks of this project" Closes #20049 See merge request gitlab-org/gitlab-ce!14355
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/forks_controller.rb8
-rw-r--r--app/finders/fork_projects_finder.rb6
2 files changed, 9 insertions, 5 deletions
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 3f83bef2c79..68978f8fdd1 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -9,14 +9,12 @@ class Projects::ForksController < Projects::ApplicationController
def index
base_query = project.forks.includes(:creator)
- @forks = base_query.merge(ProjectsFinder.new(current_user: current_user).execute)
+ forks = ForkProjectsFinder.new(project, params: params.merge(search: params[:filter_projects]), current_user: current_user).execute
@total_forks_count = base_query.size
- @private_forks_count = @total_forks_count - @forks.size
+ @private_forks_count = @total_forks_count - forks.size
@public_forks_count = @total_forks_count - @private_forks_count
- @sort = params[:sort] || 'id_desc'
- @forks = @forks.search(params[:filter_projects]) if params[:filter_projects].present?
- @forks = @forks.order_by(@sort).page(params[:page])
+ @forks = forks.page(params[:page])
respond_to do |format|
format.html
diff --git a/app/finders/fork_projects_finder.rb b/app/finders/fork_projects_finder.rb
new file mode 100644
index 00000000000..28d1b31868e
--- /dev/null
+++ b/app/finders/fork_projects_finder.rb
@@ -0,0 +1,6 @@
+class ForkProjectsFinder < ProjectsFinder
+ def initialize(project, params: {}, current_user: nil)
+ project_ids = project.forks.includes(:creator).select(:id)
+ super(params: params, current_user: current_user, project_ids_relation: project_ids)
+ end
+end