gitlab-triage 1.27.0 → 1.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6668ca8a79611f5e39d317807cb604d7fb32320120283c9996a9784515523bf5
4
- data.tar.gz: d6211b78036d039e89a75da4f93bbfa07c44b73ffd16f331ae1bfb5cc901cc9d
3
+ metadata.gz: f6db21779b13563c1dd43ffbe571507967c53dc22f4a75b61d84f2c2e5181a06
4
+ data.tar.gz: 07141e346ff6ab3eca520ed37648b5431dd4ba54307d40358331323cc46b4ddc
5
5
  SHA512:
6
- metadata.gz: bf0a6406e2a2b6f6cc6b7436831b3b95be04bbf1174c70d3fc5d4a0e24d4e8ccddcd1837864bc8e336fb1c5a0dc947c8a37716d74b31f35e025c4a21bcdb2fda
7
- data.tar.gz: 0aa64137299f30fe4f83db4b50475c2b9a15e9730eebbcf5b98d5ce17150a70379f5ae629a87b5d399ce4c74a1712063e222c224ef2e6da29d3016ca48faa35f
6
+ metadata.gz: 2acf8bcde530de9eb4365393431266f1acd824cdf48b95b8a557744503ed1af1b0a968256f8756ef337cbd7ad4b54aa330efbac2fa0632fadf628616adf3abdc
7
+ data.tar.gz: 386c9a45639c9e8603409d573e6b16e42c3cbc8d281e7af5c5faac1fac882be40c38679d9c35dccf424bb5edd284e614287426ba8e0ac1344e6b42009458fd7a
data/.gitlab/CODEOWNERS CHANGED
@@ -1,2 +1,2 @@
1
1
  # The official maintainers
2
- * @rymai @godfat-gitlab @markglenfletcher
2
+ * @gitlab-org/quality/engineering-productivity
data/README.md CHANGED
@@ -178,6 +178,7 @@ Available condition types:
178
178
  - [`draft` condition](#draft-condition)
179
179
  - [`source_branch` condition](#source-branch-condition)
180
180
  - [`target_branch` condition](#target-branch-condition)
181
+ - [`health_status` condition](#health-status-condition)
181
182
  - [`weight` condition](#weight-condition)
182
183
  - [`discussions` condition](#discussions-condition)
183
184
  - [`protected` condition](#protected-condition)
@@ -188,12 +189,12 @@ Available condition types:
188
189
 
189
190
  Accepts a hash of fields.
190
191
 
191
- | Field | Type | Values | Required |
192
- | --------- | ---- |--------------------------------------------------------------------------| -------- |
192
+ | Field | Type | Values | Required |
193
+ | --------- | ---- |----------------------------------------------------------------------------| -------- |
193
194
  | `attribute` | string | `created_at`, `updated_at`, `merged_at`, `authored_date`, `committed_date` | yes |
194
- | `condition` | string | `older_than`, `newer_than` | yes |
195
- | `interval_type` | string | `days`, `weeks`, `months`, `years` | yes |
196
- | `interval` | integer | integer | yes |
195
+ | `condition` | string | `older_than`, `newer_than` | yes |
196
+ | `interval_type` | string | `minutes`, `hours`, `days`, `weeks`, `months`, `years` | yes |
197
+ | `interval` | integer | integer | yes |
197
198
  > **Note:**
198
199
  > - `merged_at` only works on merge requests.
199
200
  > - `closed_at` is not supported in the GitLab API, but can be used in a [`ruby` condition](#ruby-condition).
@@ -210,6 +211,21 @@ conditions:
210
211
  interval: 12
211
212
  ```
212
213
 
214
+ > **Note:** If the GitLab server is giving 500 error with this option, it
215
+ > can mean that it's taking too much time to query this, and it's timing out.
216
+ > A workaround for this is that we can filter in Ruby. If you need this
217
+ > workaround, specify this with `filter_in_ruby: true`
218
+ >
219
+ > ```yaml
220
+ > conditions:
221
+ > date:
222
+ > attribute: updated_at
223
+ > condition: older_than
224
+ > interval_type: months
225
+ > interval: 12
226
+ > filter_in_ruby: true
227
+ > ```
228
+
213
229
  ##### Milestone condition
214
230
 
215
231
  Accepts the name of a milestone to filter upon. Also accepts the following timebox values:
@@ -553,6 +569,26 @@ conditions:
553
569
  target_branch: 'master'
554
570
  ```
555
571
 
572
+ ##### Health Status condition
573
+
574
+ **This condition is only applicable for issues.**
575
+
576
+ Accepts a string per the [API documentation](https://docs.gitlab.com/ee/api/issues.html#list-issues).
577
+
578
+ | State | Type | Value |
579
+ | --------- | ---- | ------ |
580
+ | Any health status | string | `Any` |
581
+ | No health status | string | `None` |
582
+ | Specific health status | string | One of `on_track`, `needs_attention` or `at_risk` |
583
+
584
+ Example:
585
+
586
+ ```yml
587
+ conditions:
588
+ health_status: Any
589
+
590
+ > **Note:** This query is not supported using GraphQL yet.
591
+
556
592
  ##### Weight condition
557
593
 
558
594
  **This condition is only applicable for issues.**
@@ -8,7 +8,8 @@ module Gitlab
8
8
  ATTRIBUTES = %w[updated_at created_at].freeze
9
9
 
10
10
  def self.applicable?(condition)
11
- ATTRIBUTES.include?(condition[:attribute].to_s)
11
+ ATTRIBUTES.include?(condition[:attribute].to_s) &&
12
+ condition[:filter_in_ruby] != true
12
13
  end
13
14
 
14
15
  def initialize(condition_hash)
@@ -2,6 +2,7 @@ require 'active_support/all'
2
2
  require 'active_support/inflector'
3
3
 
4
4
  require_relative 'expand_condition'
5
+ require_relative 'filters/issue_date_conditions_filter'
5
6
  require_relative 'filters/merge_request_date_conditions_filter'
6
7
  require_relative 'filters/branch_date_filter'
7
8
  require_relative 'filters/branch_protected_filter'
@@ -328,7 +329,7 @@ module Gitlab
328
329
  puts
329
330
  end
330
331
 
331
- def filter_resources(resources, conditions) # rubocop:disable Metrics/CyclomaticComplexity
332
+ def filter_resources(resources, conditions) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/AbcSize
332
333
  resources.select do |resource|
333
334
  results = []
334
335
 
@@ -337,8 +338,17 @@ module Gitlab
337
338
  case resource[:type]
338
339
  when 'branches'
339
340
  results << Filters::BranchDateFilter.new(resource, conditions[:date]).calculate
341
+ when 'issues'
342
+ if conditions.dig(:date, :filter_in_ruby)
343
+ results << Filters::IssueDateConditionsFilter.new(resource, conditions[:date]).calculate
344
+ end
340
345
  when 'merge_requests'
341
- results << Filters::MergeRequestDateConditionsFilter.new(resource, conditions[:date]).calculate
346
+ if conditions.dig(:date, :filter_in_ruby) ||
347
+ # REST API does not support filtering with merged_at,
348
+ # so we have to filter it in Ruby
349
+ conditions.dig(:date, :attribute) == 'merged_at'
350
+ results << Filters::MergeRequestDateConditionsFilter.new(resource, conditions[:date]).calculate
351
+ end
342
352
  end
343
353
  end
344
354
 
@@ -464,6 +474,7 @@ module Gitlab
464
474
  [].tap do |condition_builders|
465
475
  condition_builders << APIQueryBuilders::SingleQueryParamBuilder.new('weight', conditions[:weight]) if conditions[:weight]
466
476
  condition_builders << iteration_condition_builder(conditions[:iteration]) if conditions[:iteration]
477
+ condition_builders << APIQueryBuilders::SingleQueryParamBuilder.new('health_status', conditions[:health_status]) if conditions[:health_status]
467
478
  end
468
479
  end
469
480
 
@@ -6,7 +6,9 @@ module Gitlab
6
6
  class BranchDateFilter < BaseConditionsFilter
7
7
  ATTRIBUTES = %w[committed_date authored_date].freeze
8
8
  CONDITIONS = %w[older_than newer_than].freeze
9
- INTERVAL_TYPES = %w[days weeks months years].freeze
9
+ TIME_BASED_INTERVALS = %w[minutes hours].freeze
10
+ DATE_BASED_INTERVALS = %w[days weeks months years].freeze
11
+ INTERVAL_TYPES = TIME_BASED_INTERVALS + DATE_BASED_INTERVALS
10
12
 
11
13
  def self.allowed_attributes
12
14
  self::ATTRIBUTES
@@ -48,7 +50,11 @@ module Gitlab
48
50
  end
49
51
 
50
52
  def condition_value
51
- @interval.public_send(@interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
53
+ if TIME_BASED_INTERVALS.include?(@interval_type.to_s)
54
+ @interval.public_send(@interval_type).ago.to_datetime # rubocop:disable GitlabSecurity/PublicSend
55
+ else
56
+ @interval.public_send(@interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
57
+ end
52
58
  end
53
59
 
54
60
  def calculate
@@ -0,0 +1,78 @@
1
+ require_relative 'base_conditions_filter'
2
+
3
+ module Gitlab
4
+ module Triage
5
+ module Filters
6
+ class IssueDateConditionsFilter < BaseConditionsFilter
7
+ CONDITIONS = %w[older_than newer_than].freeze
8
+ TIME_BASED_INTERVALS = %w[minutes hours].freeze
9
+ DATE_BASED_INTERVALS = %w[days weeks months years].freeze
10
+ INTERVAL_TYPES = TIME_BASED_INTERVALS + DATE_BASED_INTERVALS
11
+
12
+ def self.generate_allowed_attributes
13
+ %w[updated_at created_at]
14
+ end
15
+
16
+ def self.allowed_attributes
17
+ @allowed_attributes ||= generate_allowed_attributes.freeze
18
+ end
19
+
20
+ def self.filter_parameters
21
+ [
22
+ {
23
+ name: :attribute,
24
+ type: String,
25
+ values: allowed_attributes
26
+ },
27
+ {
28
+ name: :condition,
29
+ type: String,
30
+ values: CONDITIONS
31
+ },
32
+ {
33
+ name: :interval_type,
34
+ type: String,
35
+ values: INTERVAL_TYPES
36
+ },
37
+ {
38
+ name: :interval,
39
+ type: Numeric
40
+ }
41
+ ]
42
+ end
43
+
44
+ def initialize_variables(condition)
45
+ @attribute = condition[:attribute].to_sym
46
+ @condition = condition[:condition].to_sym
47
+ @interval_type = condition[:interval_type].to_sym
48
+ @interval = condition[:interval]
49
+ end
50
+
51
+ # Guard against merge requests with no merged_at values
52
+ def resource_value
53
+ @resource[@attribute]&.to_date
54
+ end
55
+
56
+ def condition_value
57
+ if TIME_BASED_INTERVALS.include?(@interval_type.to_s)
58
+ @interval.public_send(@interval_type).ago.to_datetime # rubocop:disable GitlabSecurity/PublicSend
59
+ else
60
+ @interval.public_send(@interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
61
+ end
62
+ end
63
+
64
+ # Guard against merge requests with no merged_at values
65
+ def calculate
66
+ return false unless resource_value
67
+
68
+ case @condition
69
+ when :older_than
70
+ resource_value < condition_value
71
+ when :newer_than
72
+ resource_value > condition_value
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -3,65 +3,9 @@ require_relative 'base_conditions_filter'
3
3
  module Gitlab
4
4
  module Triage
5
5
  module Filters
6
- class MergeRequestDateConditionsFilter < BaseConditionsFilter
7
- ATTRIBUTES = %w[merged_at].freeze
8
- CONDITIONS = %w[older_than newer_than].freeze
9
- INTERVAL_TYPES = %w[days weeks months years].freeze
10
-
11
- def self.allowed_attributes
12
- self::ATTRIBUTES
13
- end
14
-
15
- def self.filter_parameters
16
- [
17
- {
18
- name: :attribute,
19
- type: String,
20
- values: allowed_attributes
21
- },
22
- {
23
- name: :condition,
24
- type: String,
25
- values: CONDITIONS
26
- },
27
- {
28
- name: :interval_type,
29
- type: String,
30
- values: INTERVAL_TYPES
31
- },
32
- {
33
- name: :interval,
34
- type: Numeric
35
- }
36
- ]
37
- end
38
-
39
- def initialize_variables(condition)
40
- @attribute = condition[:attribute].to_sym
41
- @condition = condition[:condition].to_sym
42
- @interval_type = condition[:interval_type].to_sym
43
- @interval = condition[:interval]
44
- end
45
-
46
- # Guard against merge requests with no merged_at values
47
- def resource_value
48
- @resource[@attribute]&.to_date
49
- end
50
-
51
- def condition_value
52
- @interval.public_send(@interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
53
- end
54
-
55
- # Guard against merge requests with no merged_at values
56
- def calculate
57
- return false unless resource_value
58
-
59
- case @condition
60
- when :older_than
61
- resource_value < condition_value
62
- when :newer_than
63
- resource_value > condition_value
64
- end
6
+ class MergeRequestDateConditionsFilter < IssueDateConditionsFilter
7
+ def self.generate_allowed_attributes
8
+ super << 'merged_at'
65
9
  end
66
10
  end
67
11
  end
@@ -5,7 +5,9 @@ module Gitlab
5
5
  module ParamBuilders
6
6
  class DateParamBuilder
7
7
  CONDITIONS = %w[older_than newer_than].freeze
8
- INTERVAL_TYPES = %w[days weeks months years].freeze
8
+ TIME_BASED_INTERVALS = %w[minutes hours].freeze
9
+ DATE_BASED_INTERVALS = %w[days weeks months years].freeze
10
+ INTERVAL_TYPES = TIME_BASED_INTERVALS + DATE_BASED_INTERVALS
9
11
 
10
12
  def initialize(allowed_attributes, condition_hash)
11
13
  @allowed_attributes = allowed_attributes
@@ -18,7 +20,11 @@ module Gitlab
18
20
  end
19
21
 
20
22
  def param_content
21
- interval.public_send(interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
23
+ if TIME_BASED_INTERVALS.include?(interval_type)
24
+ interval.public_send(interval_type).ago.to_datetime # rubocop:disable GitlabSecurity/PublicSend
25
+ else
26
+ interval.public_send(interval_type).ago.to_date # rubocop:disable GitlabSecurity/PublicSend
27
+ end
22
28
  end
23
29
 
24
30
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.27.0'
5
+ VERSION = '1.28.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-triage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.27.0
4
+ version: 1.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -201,6 +201,7 @@ files:
201
201
  - lib/gitlab/triage/filters/branch_date_filter.rb
202
202
  - lib/gitlab/triage/filters/branch_protected_filter.rb
203
203
  - lib/gitlab/triage/filters/discussions_conditions_filter.rb
204
+ - lib/gitlab/triage/filters/issue_date_conditions_filter.rb
204
205
  - lib/gitlab/triage/filters/member_conditions_filter.rb
205
206
  - lib/gitlab/triage/filters/merge_request_date_conditions_filter.rb
206
207
  - lib/gitlab/triage/filters/name_conditions_filter.rb