diff options
author | Valery Sizov <valery@gitlab.com> | 2015-09-18 08:54:06 +0000 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2015-09-18 08:54:06 +0000 |
commit | 3984818bb37ca8da8fdc7fb5e61f7cfc0a329ac4 (patch) | |
tree | 8970a0f54e8841dbe2f79960e229f3d4a129afd9 /app/controllers/ci | |
parent | 0aec0d53b10078613b66b0d41424ee4264ae6406 (diff) | |
parent | b7e49d8042629dd0e5b9feade78e058a737f96b2 (diff) | |
download | gitlab-ce-3984818bb37ca8da8fdc7fb5e61f7cfc0a329ac4.tar.gz |
Merge branch 'ci_projects_order' into 'master'
Fix: ci projects order
https://gitlab.com/gitlab-org/gitlab-ce/issues/2553
See merge request !1333
Diffstat (limited to 'app/controllers/ci')
-rw-r--r-- | app/controllers/ci/projects_controller.rb | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb index 6483a84ee91..653384b7178 100644 --- a/app/controllers/ci/projects_controller.rb +++ b/app/controllers/ci/projects_controller.rb @@ -5,38 +5,32 @@ module Ci before_action :authenticate_user!, except: [:build, :badge, :index, :show] before_action :authenticate_public_page!, only: :show before_action :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml] - before_action :authorize_access_project!, except: [:build, :gitlab, :badge, :index, :show, :new, :create] + before_action :authorize_access_project!, except: [:build, :badge, :index, :show, :new, :create] before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml] before_action :authenticate_token!, only: [:build] before_action :no_cache, only: [:badge] protect_from_forgery except: :build - layout 'ci/project', except: [:index, :gitlab] + layout 'ci/project', except: :index def index - @projects = Ci::Project.ordered_by_last_commit_date.public_only.page(params[:page]) unless current_user - end - - def gitlab @limit, @offset = (params[:limit] || PROJECTS_BATCH).to_i, (params[:offset] || 0).to_i @page = @offset == 0 ? 1 : (@offset / @limit + 1) - @gl_projects = current_user.authorized_projects - @gl_projects = @gl_projects.where("name LIKE ?", "%#{params[:search]}%") if params[:search] - @gl_projects = @gl_projects.page(@page).per(@limit) + if current_user + @projects = ProjectListBuilder.new.execute(current_user, params[:search]) - @projects = Ci::Project.where(gitlab_id: @gl_projects.map(&:id)).ordered_by_last_commit_date - @total_count = @gl_projects.size + @projects = @projects.page(@page).per(@limit) - @gl_projects = @gl_projects.where.not(id: @projects.map(&:gitlab_id)) + @total_count = @projects.size + end respond_to do |format| format.json do - pager_json("ci/projects/gitlab", @total_count) + pager_json("ci/projects/index", @total_count) end + format.html end - rescue - @error = 'Failed to fetch GitLab projects' end def show |