checkoff 0.26.0 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/checkoff/internal/search_url/custom_field_param_converter.rb +1 -0
- data/lib/checkoff/internal/search_url/custom_field_variant.rb +42 -23
- data/lib/checkoff/internal/task_selector_evaluator.rb +35 -15
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bac942429684609678acb06e7426577be0bfd0239b9bf7ca4123e71484125746
|
4
|
+
data.tar.gz: 5cad1409ce70028e43f52789878b3d2cbcfaceb3bfcd26b230890a27d9d87fbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b68f2aa40aef9ecfe7fb4fbbe1bfac3b48f99c7cdf4ed1ed6308f93e3f4ac9f0d8b289bd5e82a7e1e05ee189b9fc62ca7cf6e07a237cb5d626318509ec24f5b8
|
7
|
+
data.tar.gz: 493cc1f59007c7fce4146e3bebae38a9447fa57cf418079afd835783529f8952c981e4bf86819fc8ec66f40f2c32a251da43fccafaf064316bee90f8bdbf781a
|
data/Gemfile.lock
CHANGED
@@ -49,6 +49,7 @@ module Checkoff
|
|
49
49
|
VARIANTS = {
|
50
50
|
'is' => CustomFieldVariant::Is,
|
51
51
|
'no_value' => CustomFieldVariant::NoValue,
|
52
|
+
'any_value' => CustomFieldVariant::AnyValue,
|
52
53
|
'is_not' => CustomFieldVariant::IsNot,
|
53
54
|
'less_than' => CustomFieldVariant::LessThan,
|
54
55
|
'greater_than' => CustomFieldVariant::GreaterThan,
|
@@ -16,6 +16,12 @@ module Checkoff
|
|
16
16
|
|
17
17
|
attr_reader :gid, :remaining_params
|
18
18
|
|
19
|
+
def ensure_no_remaining_params!
|
20
|
+
return if remaining_params.length.zero?
|
21
|
+
|
22
|
+
raise "Teach me how to handle these remaining keys: #{remaining_params}"
|
23
|
+
end
|
24
|
+
|
19
25
|
def fetch_solo_param(param_name)
|
20
26
|
case remaining_params.keys
|
21
27
|
when [param_name]
|
@@ -96,39 +102,52 @@ module Checkoff
|
|
96
102
|
# custom_field_#{gid}.variant = 'no_value'
|
97
103
|
class NoValue < CustomFieldVariant
|
98
104
|
def convert
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
+
ensure_no_remaining_params!
|
106
|
+
|
107
|
+
api_params = { "custom_fields.#{gid}.is_set" => 'false' }
|
108
|
+
# As of 2023-02, the 'is_set' => 'false' seems to not do
|
109
|
+
# the intuitive thing on multi-select fields; it either
|
110
|
+
# operates as a no-op or operates the same as 'true'; not
|
111
|
+
# sure.
|
112
|
+
#
|
113
|
+
# Let's handle those with a filter afterwards.
|
114
|
+
task_selector = [:nil?, [:custom_field_gid_value, gid]]
|
115
|
+
[api_params, task_selector]
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
108
|
-
# custom_field_#{gid}.variant = '
|
109
|
-
|
119
|
+
# custom_field_#{gid}.variant = 'any_value'
|
120
|
+
#
|
121
|
+
# Not used for multi-select fields
|
122
|
+
class AnyValue < CustomFieldVariant
|
110
123
|
def convert
|
111
|
-
|
112
|
-
raise "Teach me how to handle these remaining keys for #{variant_key}: #{remaining_params}"
|
113
|
-
end
|
124
|
+
ensure_no_remaining_params!
|
114
125
|
|
115
|
-
|
116
|
-
|
126
|
+
api_params = { "custom_fields.#{gid}.is_set" => 'true' }
|
127
|
+
task_selector = []
|
128
|
+
[api_params, task_selector]
|
117
129
|
end
|
130
|
+
end
|
118
131
|
|
119
|
-
|
132
|
+
# custom_field_#{gid}.variant = 'is'
|
133
|
+
class Is < CustomFieldVariant
|
134
|
+
def convert
|
135
|
+
selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
|
120
136
|
|
121
|
-
def convert_custom_field_is_arg(key, values)
|
122
137
|
empty_task_selector = []
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
138
|
+
if selected_options.length == 1
|
139
|
+
[{ "custom_fields.#{gid}.value" => selected_options[0] },
|
140
|
+
empty_task_selector]
|
141
|
+
else
|
142
|
+
# As of 2023-01,
|
143
|
+
# https://developers.asana.com/reference/searchtasksforworkspace
|
144
|
+
# says "Not Supported: searching for multiple exact
|
145
|
+
# matches of a custom field". So I guess we have to
|
146
|
+
# search this manually.
|
147
|
+
api_params = { "custom_fields.#{gid}.is_set" => 'true' }
|
148
|
+
task_selector = [:custom_field_gid_value_contains_any_gid, gid, selected_options]
|
149
|
+
[api_params, task_selector]
|
129
150
|
end
|
130
|
-
|
131
|
-
raise "Teach me how to handle #{key} = #{values}"
|
132
151
|
end
|
133
152
|
end
|
134
153
|
end
|
@@ -17,6 +17,21 @@ module Checkoff
|
|
17
17
|
object.is_a?(Array) && !object.empty? && [fn_name, fn_name.to_s].include?(object[0])
|
18
18
|
end
|
19
19
|
|
20
|
+
def pull_custom_field_or_raise(task, custom_field_gid)
|
21
|
+
custom_fields = task.custom_fields
|
22
|
+
if custom_fields.nil?
|
23
|
+
raise "Could not find custom_fields under task (was 'custom_fields' included in 'extra_fields'?)"
|
24
|
+
end
|
25
|
+
|
26
|
+
matched_custom_field = custom_fields.find { |data| data.fetch('gid') == custom_field_gid }
|
27
|
+
if matched_custom_field.nil?
|
28
|
+
raise "Could not find custom field with gid #{custom_field_gid} " \
|
29
|
+
"in task #{task.gid} with custom fields #{custom_fields}"
|
30
|
+
end
|
31
|
+
|
32
|
+
matched_custom_field
|
33
|
+
end
|
34
|
+
|
20
35
|
attr_reader :task_selector
|
21
36
|
end
|
22
37
|
|
@@ -91,6 +106,22 @@ module Checkoff
|
|
91
106
|
end
|
92
107
|
end
|
93
108
|
|
109
|
+
# :custom_field_gid_value function
|
110
|
+
class CustomFieldGidValueFunctionEvaluator < FunctionEvaluator
|
111
|
+
def matches?
|
112
|
+
fn?(task_selector, :custom_field_gid_value)
|
113
|
+
end
|
114
|
+
|
115
|
+
def evaluate_arg?(_index)
|
116
|
+
false
|
117
|
+
end
|
118
|
+
|
119
|
+
def evaluate(task, custom_field_gid)
|
120
|
+
custom_field = pull_custom_field_or_raise(task, custom_field_gid)
|
121
|
+
custom_field['display_value']
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
94
125
|
# :custom_field_gid_value_contains_any_gid function
|
95
126
|
class CustomFieldGidValueContainsAnyGidFunctionEvaluator < FunctionEvaluator
|
96
127
|
def matches?
|
@@ -104,25 +135,13 @@ module Checkoff
|
|
104
135
|
def evaluate(task, custom_field_gid, custom_field_values_gids)
|
105
136
|
actual_custom_field_values_gids = pull_custom_field_values_gids(task, custom_field_gid)
|
106
137
|
|
107
|
-
|
138
|
+
actual_custom_field_values_gids.any? do |custom_field_value|
|
139
|
+
custom_field_values_gids.include?(custom_field_value)
|
140
|
+
end
|
108
141
|
end
|
109
142
|
|
110
143
|
private
|
111
144
|
|
112
|
-
def pull_custom_field_or_raise(task, custom_field_gid)
|
113
|
-
custom_fields = task.custom_fields
|
114
|
-
if custom_fields.nil?
|
115
|
-
raise "Could not find custom_fields under task (was 'custom_fields' included in 'extra_fields'?)"
|
116
|
-
end
|
117
|
-
|
118
|
-
matched_custom_field = custom_fields.find { |data| data.fetch('gid') == custom_field_gid }
|
119
|
-
if matched_custom_field.nil?
|
120
|
-
raise "Could not find custom field with gid #{custom_field_gid} in #{task.gid} with #{custom_fields}"
|
121
|
-
end
|
122
|
-
|
123
|
-
matched_custom_field
|
124
|
-
end
|
125
|
-
|
126
145
|
def pull_enum_values(custom_field)
|
127
146
|
resource_subtype = custom_field.fetch('resource_subtype')
|
128
147
|
case resource_subtype
|
@@ -164,6 +183,7 @@ module Checkoff
|
|
164
183
|
NilPFunctionEvaluator,
|
165
184
|
TagPFunctionEvaluator,
|
166
185
|
CustomFieldValueFunctionEvaluator,
|
186
|
+
CustomFieldGidValueFunctionEvaluator,
|
167
187
|
CustomFieldGidValueContainsAnyGidFunctionEvaluator,
|
168
188
|
AndFunctionEvaluator,
|
169
189
|
].freeze
|
data/lib/checkoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vince Broz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|