From 1617a541fe117e110cba375adafff47a35d8627b Mon Sep 17 00:00:00 2001 From: Jasder <2053003901@@qq.com> Date: Tue, 25 Aug 2020 15:59:53 +0800 Subject: [PATCH] FIX code review --- app/models/ci/build.rb | 2 +- app/queries/ci/builds/list_query.rb | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index e1d1832f4..a96e1cfd8 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -8,6 +8,6 @@ class Ci::Build < Ci::RemoteBase scope :failed, -> { by_status('failure') } scope :running, -> { by_status('running') } scope :errored, -> { by_status('error') } - scope :pending, -> { by_status('pending') } + scope :pending, -> { by_status('pending') } scope :by_status, ->(status) { where(build_status: status) } end diff --git a/app/queries/ci/builds/list_query.rb b/app/queries/ci/builds/list_query.rb index 4577045f6..fb5034811 100644 --- a/app/queries/ci/builds/list_query.rb +++ b/app/queries/ci/builds/list_query.rb @@ -13,21 +13,16 @@ class Ci::Builds::ListQuery < ApplicationQuery def call scope = @repo.builds - scope = + builds = case params[:search] - when 'success' - scope.successed - when 'pending' - scope.pending - when 'error' - scope.errored - when 'running' - scope.running - when 'failure' - scope.failed + when 'success' then scope.successed + when 'pending' then scope.pending + when 'error' then scope.errored + when 'running' then scope.running + when 'failure' then scope.failed else scope end - custom_sort(scope, params[:sort_by], params[:sort_direction]) + custom_sort(builds, params[:sort_by], params[:sort_direction]) end end