apadmi_grout 2.3.2 → 2.5.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: 9c2b3bf66e39fb59a2aa78864a22c847a4ce2cb56d111045bce2a45f4b4a3431
4
- data.tar.gz: 55d07c67f65c048ef492689f74b90f9f52e1c97a4faf385ee18777115e6c94f4
3
+ metadata.gz: fe89f35f8c3b54c1f9e69bd1f0fe9d18c38ccab135960467d5df0753a4eb1fdc
4
+ data.tar.gz: '0982cf4af81f777753799820e9a0cad205f5e052f8e7ae48765b2366c61f23b3'
5
5
  SHA512:
6
- metadata.gz: e6389e3c9b81b3f577b49fd1dd40c74320fe25082b1eb421ca53a4c3d3b6b5bc194d0735746a309f40857aa8ab204f956cefdd3445c63b30502170dde32a6738
7
- data.tar.gz: 906d59910dedd1c6e96bd5ed43a76cccaaedaf8be6c1ce27d048bde5bbee3306b74695a14f3866d17d579e7c87e43822e7c322fcf113385aac8fb59974467781
6
+ metadata.gz: ee076a7a629461753bf73c84ea78698ff7430afba999ff5c3695c80d9013dd36a4af3c1033198de37d9f610b2f0e6d1f1adab774f4c7fabd001124c3bb78be78
7
+ data.tar.gz: 28a4867d73f83d8ab6e0ab4d28c63cdbd8f166237edb28ae305325e7b029dbe6a126526f1f388ac8fc877fe298250b6a11e54bb7ecf2623cc21bcb6ffef09049
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Core Changelog
2
2
 
3
+ ## [2.5.0] - 2023-09-20
4
+ * Added more options to the ADO queries for more in granular filtering.
5
+
6
+ ## [2.4.0] - 2023-09-04
7
+ * No change - keeping version in sync with fastlane plugin.
8
+
3
9
  ## [2.3.2] - 2023-04-06
4
10
  * Add utility for parsing build variant from android build command
5
11
 
@@ -25,11 +25,12 @@ module Apadmi
25
25
 
26
26
  # Ado specific find tickets options
27
27
  class AdoFindTicketsOptions < FindTicketsOptions
28
- attr_reader :required_tags, :not_tags
28
+ attr_reader :required_tags, :not_tags, :additional_fields
29
29
 
30
- def initialize(required_tags: [], not_tags: [])
30
+ def initialize(required_tags: [], not_tags: [], additional_fields: {})
31
31
  @required_tags = required_tags
32
32
  @not_tags = not_tags
33
+ @additional_fields = additional_fields
33
34
  end
34
35
 
35
36
  def ==(other)
@@ -37,7 +38,7 @@ module Apadmi
37
38
  end
38
39
 
39
40
  def state
40
- [@required_tags, @not_tags]
41
+ [@required_tags, @not_tags, @additional_fields]
41
42
  end
42
43
  end
43
44
  end
@@ -40,24 +40,16 @@ module Apadmi
40
40
 
41
41
  # @return [Array<Apadmi::Grout::Issue>]
42
42
  def search_unblocked_issues(component, status, ticket_types = [], options = nil)
43
- tags = (options&.required_tags || []).push(*component).filter { |it| !it.blank? }
44
- not_tags = (options&.not_tags || []).filter { |it| !it.blank? }
45
-
46
- raise "Tags can either be required or not required, not both" unless (tags & not_tags).empty?
47
-
48
- tags_filter = tags.map { |tag| " AND [System.Tags] CONTAINS '#{tag}' " }.join(" ")
49
- not_tags_filter = not_tags.map { |tag| " AND [System.Tags] NOT CONTAINS '#{tag}'" }.join(" ")
50
-
51
43
  status_filter = ("AND [System.State]='#{status}' " unless status.blank?) || ""
52
44
  type_filter = ("AND [System.WorkItemType] IN (#{ticket_types.map { |t| "'#{t}'" }.join(", ")})" unless ticket_types.empty?) || ""
45
+ options_filter = get_options_filter(component, options)
53
46
  wiql = %(
54
47
  Select [System.Id]
55
48
  From WorkItems
56
49
  Where [System.Id] >= 1
57
50
  #{status_filter}
58
- #{tags_filter}
59
- #{not_tags_filter}
60
51
  #{type_filter}
52
+ #{options_filter}
61
53
  )
62
54
 
63
55
  get_issues_by_wiql(wiql)
@@ -194,6 +186,28 @@ module Apadmi
194
186
  ids = items.map { |item| item["id"] } || []
195
187
  find_issues_by_keys(ids)
196
188
  end
189
+
190
+ # @param component [String] Included to be consistent with JIRA, this will boil down to a tag in ADO
191
+ # @param options [Apadmi::Grout::AdoFindTicketsOptions] options as defined to query
192
+
193
+ # @return [String]
194
+ def get_options_filter(component, options = nil)
195
+ tags = (options&.required_tags || []).push(*component).filter { |it| !it.blank? }
196
+ not_tags = (options&.not_tags || []).filter { |it| !it.blank? }
197
+ additional_fields = (options&.additional_fields || {}).reject { |k, _v| k.blank? }
198
+
199
+ raise "Tags can either be required or not required, not both" unless (tags & not_tags).empty?
200
+
201
+ tags_filter = tags.map { |tag| " AND [System.Tags] CONTAINS '#{tag}' " }.join(" ")
202
+ not_tags_filter = not_tags.map { |tag| " AND [System.Tags] NOT CONTAINS '#{tag}'" }.join(" ")
203
+ additional_fields_filter = additional_fields.collect { |k, v| "AND [#{k}]='#{v}'" }.join(" ")
204
+
205
+ %(
206
+ #{tags_filter}
207
+ #{not_tags_filter}
208
+ #{additional_fields_filter}
209
+ )
210
+ end
197
211
  end
198
212
  end
199
213
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Apadmi
4
4
  module Grout
5
- VERSION = "2.3.2"
5
+ VERSION = "2.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apadmi_grout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Apadmi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-06 00:00:00.000000000 Z
11
+ date: 2023-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday