From e9d94451959e4717e0ba4ca882b5a54437efbee1 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 21 Feb 2017 17:20:50 +0900 Subject: - Add new parameters for Pipeline API - Expand PipelinesFinder functions --- lib/api/pipelines.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 754c3d85a04..905e72a3a95 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -16,11 +16,21 @@ module API use :pagination optional :scope, type: String, values: %w(running branches tags), desc: 'Either running, branches, or tags' + optional :status, type: String, values: ['running', 'pending', 'success', 'failed', 'canceled', 'skipped'], + desc: 'Pipeline Status' + optional :ref, type: String, desc: 'Pipeline Ref' + optional :duration, type: Integer, desc: 'Greater than the specified duration' + optional :yaml_error, type: Boolean, desc: 'If true, returns only yaml error pipelines.' + optional :user_id, type: String, desc: 'User who executed pipelines' + optional :order_by, type: String, values: ['id', 'status', 'ref', 'user_id', 'started_at', 'finished_at', 'created_at', 'updated_at'], default: 'id', + desc: 'Return issues ordered by `created_at` or `updated_at` fields.' + optional :sort, type: String, values: ['asc', 'desc'], default: 'desc', + desc: 'Return pipelines sorted in `asc` or `desc` order.' end get ':id/pipelines' do authorize! :read_pipeline, user_project - pipelines = PipelinesFinder.new(user_project).execute(scope: params[:scope]) + pipelines = PipelinesFinder.new(user_project, params).execute(scope: params[:scope]) present paginate(pipelines), with: Entities::PipelineBasic end -- cgit v1.2.1 From 994e49b3fbc261f8e59429c1681d83c81ba25df3 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 28 Feb 2017 21:24:49 +0900 Subject: Fixed those points. - username to user_id - Drop duration - Resolve comments - Add Changelog - Edit docs --- lib/api/pipelines.rb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 905e72a3a95..48ab5c21780 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -14,18 +14,17 @@ module API end params do use :pagination - optional :scope, type: String, values: %w(running branches tags), - desc: 'Either running, branches, or tags' + optional :scope, type: String, values: %w(running pending finished branches tags), + desc: 'The scope of pipelines' optional :status, type: String, values: ['running', 'pending', 'success', 'failed', 'canceled', 'skipped'], - desc: 'Pipeline Status' - optional :ref, type: String, desc: 'Pipeline Ref' - optional :duration, type: Integer, desc: 'Greater than the specified duration' - optional :yaml_error, type: Boolean, desc: 'If true, returns only yaml error pipelines.' - optional :user_id, type: String, desc: 'User who executed pipelines' + desc: 'The status of pipelines' + optional :ref, type: String, desc: 'The ref of pipelines' + optional :yaml_errors, type: Boolean, desc: 'If true, Returns only yaml error pipelines' + optional :username, type: String, desc: 'The name of user who triggered pipelines' optional :order_by, type: String, values: ['id', 'status', 'ref', 'user_id', 'started_at', 'finished_at', 'created_at', 'updated_at'], default: 'id', - desc: 'Return issues ordered by `created_at` or `updated_at` fields.' + desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: ['asc', 'desc'], default: 'desc', - desc: 'Return pipelines sorted in `asc` or `desc` order.' + desc: 'The sort method which is combined with an order_by' end get ':id/pipelines' do authorize! :read_pipeline, user_project -- cgit v1.2.1 From df834306c1794ed72d6d655c7941dee28f7e85c7 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 1 Mar 2017 02:34:48 +0900 Subject: Add specs. Plus, minor fixes. --- lib/api/pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 48ab5c21780..ecd6b64cfa7 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -21,7 +21,7 @@ module API optional :ref, type: String, desc: 'The ref of pipelines' optional :yaml_errors, type: Boolean, desc: 'If true, Returns only yaml error pipelines' optional :username, type: String, desc: 'The name of user who triggered pipelines' - optional :order_by, type: String, values: ['id', 'status', 'ref', 'user_id', 'started_at', 'finished_at', 'created_at', 'updated_at'], default: 'id', + optional :order_by, type: String, values: ['id', 'status', 'ref', 'username', 'started_at', 'finished_at', 'created_at', 'updated_at'], default: 'id', desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: ['asc', 'desc'], default: 'desc', desc: 'The sort method which is combined with an order_by' -- cgit v1.2.1 From fd302061f915f535b2dd419d5a76efb76ab534be Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 1 Mar 2017 15:58:06 +0900 Subject: Fix rubocop offences and rspec failures --- lib/api/pipelines.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index ecd6b64cfa7..70837d91c7a 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -16,14 +16,14 @@ module API use :pagination optional :scope, type: String, values: %w(running pending finished branches tags), desc: 'The scope of pipelines' - optional :status, type: String, values: ['running', 'pending', 'success', 'failed', 'canceled', 'skipped'], + optional :status, type: String, values: %w(running pending success failed canceled skipped), desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' optional :yaml_errors, type: Boolean, desc: 'If true, Returns only yaml error pipelines' optional :username, type: String, desc: 'The name of user who triggered pipelines' - optional :order_by, type: String, values: ['id', 'status', 'ref', 'username', 'started_at', 'finished_at', 'created_at', 'updated_at'], default: 'id', + optional :order_by, type: String, values: %w(id status ref username started_at finished_at created_at updated_at), default: 'id', desc: 'The order_by which is combined with a sort' - optional :sort, type: String, values: ['asc', 'desc'], default: 'desc', + optional :sort, type: String, values: %w(asc desc), default: 'desc', desc: 'The sort method which is combined with an order_by' end get ':id/pipelines' do -- cgit v1.2.1 From af7cb5b93191453de4ff7561089bb0b0146c688f Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 7 Mar 2017 21:36:45 +0900 Subject: %w() to %[] --- lib/api/pipelines.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 70837d91c7a..fcec7e7d3bb 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -14,16 +14,16 @@ module API end params do use :pagination - optional :scope, type: String, values: %w(running pending finished branches tags), + optional :scope, type: String, values: %[running pending finished branches tags], desc: 'The scope of pipelines' - optional :status, type: String, values: %w(running pending success failed canceled skipped), + optional :status, type: String, values: %[running pending success failed canceled skipped], desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' - optional :yaml_errors, type: Boolean, desc: 'If true, Returns only yaml error pipelines' + optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :username, type: String, desc: 'The name of user who triggered pipelines' - optional :order_by, type: String, values: %w(id status ref username started_at finished_at created_at updated_at), default: 'id', + optional :order_by, type: String, values: %[id status ref username started_at finished_at created_at updated_at], default: 'id', desc: 'The order_by which is combined with a sort' - optional :sort, type: String, values: %w(asc desc), default: 'desc', + optional :sort, type: String, values: %[asc desc], default: 'desc', desc: 'The sort method which is combined with an order_by' end get ':id/pipelines' do -- cgit v1.2.1 From d33e762167a197f30d075ed409ca1a07ae9f83c6 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 7 Mar 2017 22:02:29 +0900 Subject: %[] to %w[] --- lib/api/pipelines.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index fcec7e7d3bb..bcb4fdcfe47 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -14,16 +14,16 @@ module API end params do use :pagination - optional :scope, type: String, values: %[running pending finished branches tags], + optional :scope, type: String, values: %w[running pending finished branches tags], desc: 'The scope of pipelines' - optional :status, type: String, values: %[running pending success failed canceled skipped], + optional :status, type: String, values: %w[running pending success failed canceled skipped], desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :username, type: String, desc: 'The name of user who triggered pipelines' - optional :order_by, type: String, values: %[id status ref username started_at finished_at created_at updated_at], default: 'id', + optional :order_by, type: String, values: %w[id status ref username started_at finished_at created_at updated_at], default: 'id', desc: 'The order_by which is combined with a sort' - optional :sort, type: String, values: %[asc desc], default: 'desc', + optional :sort, type: String, values: %w[asc desc], default: 'desc', desc: 'The sort method which is combined with an order_by' end get ':id/pipelines' do -- cgit v1.2.1 From 56f50cbb3a63ae914f50eda3756b49d5cf516207 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 8 Mar 2017 17:24:20 +0900 Subject: Fix how to use PipelinesFinder --- lib/api/pipelines.rb | 2 +- lib/api/v3/pipelines.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index bcb4fdcfe47..986dd607e23 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -29,7 +29,7 @@ module API get ':id/pipelines' do authorize! :read_pipeline, user_project - pipelines = PipelinesFinder.new(user_project, params).execute(scope: params[:scope]) + pipelines = PipelinesFinder.new(user_project, params).execute present paginate(pipelines), with: Entities::PipelineBasic end diff --git a/lib/api/v3/pipelines.rb b/lib/api/v3/pipelines.rb index 82827249244..c48cbd2b765 100644 --- a/lib/api/v3/pipelines.rb +++ b/lib/api/v3/pipelines.rb @@ -21,7 +21,7 @@ module API get ':id/pipelines' do authorize! :read_pipeline, user_project - pipelines = PipelinesFinder.new(user_project).execute(scope: params[:scope]) + pipelines = PipelinesFinder.new(user_project, scope: params[:scope]).execute present paginate(pipelines), with: ::API::Entities::Pipeline end end -- cgit v1.2.1 From 175800299bf497591e625e82fd71420644c0bc6b Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 8 Mar 2017 20:24:00 +0900 Subject: Add name(User) --- lib/api/pipelines.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 986dd607e23..79eea7e2e28 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -20,7 +20,8 @@ module API desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' - optional :username, type: String, desc: 'The name of user who triggered pipelines' + optional :name, type: String, desc: 'The name of user who triggered pipelines' + optional :username, type: String, desc: 'The username of user who triggered pipelines' optional :order_by, type: String, values: %w[id status ref username started_at finished_at created_at updated_at], default: 'id', desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: %w[asc desc], default: 'desc', -- cgit v1.2.1 From 9324a464ef456dff3670df227c10d5cdec473256 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 8 Mar 2017 21:18:09 +0900 Subject: Reduce playable columns for sorting --- lib/api/pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 79eea7e2e28..7d91900212a 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -22,7 +22,7 @@ module API optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :name, type: String, desc: 'The name of user who triggered pipelines' optional :username, type: String, desc: 'The username of user who triggered pipelines' - optional :order_by, type: String, values: %w[id status ref username started_at finished_at created_at updated_at], default: 'id', + optional :order_by, type: String, values: %w[id status ref sha user_id], default: 'id', desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: %w[asc desc], default: 'desc', desc: 'The sort method which is combined with an order_by' -- cgit v1.2.1 From d1ca5f46d4268ca3bba7801e581395e038c97129 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Tue, 14 Mar 2017 23:52:17 +0900 Subject: No need to support sha for sorting --- lib/api/pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 7d91900212a..b0f586b08da 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -22,7 +22,7 @@ module API optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :name, type: String, desc: 'The name of user who triggered pipelines' optional :username, type: String, desc: 'The username of user who triggered pipelines' - optional :order_by, type: String, values: %w[id status ref sha user_id], default: 'id', + optional :order_by, type: String, values: %w[id status ref user_id], default: 'id', desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: %w[asc desc], default: 'desc', desc: 'The sort method which is combined with an order_by' -- cgit v1.2.1 From 22a4d124f70598c7c21b08b11db3f38c7bcb71ec Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 22 Mar 2017 02:37:19 +0900 Subject: Use JSON type for sorting parameter (halfway) --- lib/api/pipelines.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index b0f586b08da..6bbb679cb5e 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -22,10 +22,10 @@ module API optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :name, type: String, desc: 'The name of user who triggered pipelines' optional :username, type: String, desc: 'The username of user who triggered pipelines' - optional :order_by, type: String, values: %w[id status ref user_id], default: 'id', - desc: 'The order_by which is combined with a sort' - optional :sort, type: String, values: %w[asc desc], default: 'desc', - desc: 'The sort method which is combined with an order_by' + optional :sort, type: JSON, desc: 'order_by and asc_desc' do + requires :order_by, type: String, values: %w[id status ref user_id] + requires :asc_desc, type: String, values: %w[asc desc] + end end get ':id/pipelines' do authorize! :read_pipeline, user_project -- cgit v1.2.1 From 0e8266f2386351906e2d6357282e011d373b2c94 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 24 Mar 2017 16:06:19 +0900 Subject: Revert "Use JSON type for sorting parameter (halfway)" This reverts commit 34127cb13ad72f65a24bdc8fc051363d3edd77cb. --- lib/api/pipelines.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 6bbb679cb5e..b0f586b08da 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -22,10 +22,10 @@ module API optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :name, type: String, desc: 'The name of user who triggered pipelines' optional :username, type: String, desc: 'The username of user who triggered pipelines' - optional :sort, type: JSON, desc: 'order_by and asc_desc' do - requires :order_by, type: String, values: %w[id status ref user_id] - requires :asc_desc, type: String, values: %w[asc desc] - end + optional :order_by, type: String, values: %w[id status ref user_id], default: 'id', + desc: 'The order_by which is combined with a sort' + optional :sort, type: String, values: %w[asc desc], default: 'desc', + desc: 'The sort method which is combined with an order_by' end get ':id/pipelines' do authorize! :read_pipeline, user_project -- cgit v1.2.1 From 0a36bfa994582b690a7935fed4c15d42b22bd0ed Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 30 Mar 2017 18:59:45 +0900 Subject: Use HasStatus::AVAILABLE_STATUSES instead of hard coding --- lib/api/pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index b0f586b08da..29757dd9935 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -16,7 +16,7 @@ module API use :pagination optional :scope, type: String, values: %w[running pending finished branches tags], desc: 'The scope of pipelines' - optional :status, type: String, values: %w[running pending success failed canceled skipped], + optional :status, type: String, values: HasStatus::AVAILABLE_STATUSES, desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' -- cgit v1.2.1 From 8653c2dfc943b5536ab99155c8b950e30ba1f567 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 30 Mar 2017 19:30:02 +0900 Subject: Add constant as ALLOWED_INDEXED_COLUMNS --- lib/api/pipelines.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 29757dd9935..6a054544d70 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -22,7 +22,7 @@ module API optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' optional :name, type: String, desc: 'The name of user who triggered pipelines' optional :username, type: String, desc: 'The username of user who triggered pipelines' - optional :order_by, type: String, values: %w[id status ref user_id], default: 'id', + optional :order_by, type: String, values: PipelinesFinder::ALLOWED_INDEXED_COLUMNS, default: 'id', desc: 'The order_by which is combined with a sort' optional :sort, type: String, values: %w[asc desc], default: 'desc', desc: 'The sort method which is combined with an order_by' -- cgit v1.2.1 From 255bfd658340e36a882108d4a9911d7f9cde638d Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 27 Apr 2017 22:09:18 +0900 Subject: Improve documentation --- lib/api/pipelines.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb index 6a054544d70..9117704aa46 100644 --- a/lib/api/pipelines.rb +++ b/lib/api/pipelines.rb @@ -19,13 +19,13 @@ module API optional :status, type: String, values: HasStatus::AVAILABLE_STATUSES, desc: 'The status of pipelines' optional :ref, type: String, desc: 'The ref of pipelines' - optional :yaml_errors, type: Boolean, desc: 'If true, returns only yaml error pipelines' - optional :name, type: String, desc: 'The name of user who triggered pipelines' - optional :username, type: String, desc: 'The username of user who triggered pipelines' + optional :yaml_errors, type: Boolean, desc: 'Returns pipelines with invalid configurations' + optional :name, type: String, desc: 'The name of the user who triggered pipelines' + optional :username, type: String, desc: 'The username of the user who triggered pipelines' optional :order_by, type: String, values: PipelinesFinder::ALLOWED_INDEXED_COLUMNS, default: 'id', - desc: 'The order_by which is combined with a sort' + desc: 'Order pipelines' optional :sort, type: String, values: %w[asc desc], default: 'desc', - desc: 'The sort method which is combined with an order_by' + desc: 'Sort pipelines' end get ':id/pipelines' do authorize! :read_pipeline, user_project -- cgit v1.2.1