checkoff 0.22.0 → 0.24.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 +2 -0
- data/lib/checkoff/internal/search_url/custom_field_variant.rb +40 -28
- data/lib/checkoff/internal/task_selector_evaluator.rb +27 -11
- 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: 26474f8f2f94c75d46d16eadd8c773a22d139d56e0d4bcaaae4c698519e8fa89
|
4
|
+
data.tar.gz: fc1b3a92a5736360fec289c1f2c156bc6570ad465fe8ecfdaa63a1b5a10cef5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80a903a43039264b205cb4ae61f4637360d8a9b4db4cf47062fd4d8e0ed127f420e6da5baebb30c2cbde792261c2265133157f45a19f7cfea8f0577b862327ac
|
7
|
+
data.tar.gz: f6a30feeda861f28f96bb8a7a6b38d68bd3a4042bf21b7521c4382c1b2107aeee8a04c405d5f79fe7fec0acfe27bce778f48ff93c00d27bc552b3f0e531a0359
|
data/Gemfile.lock
CHANGED
@@ -48,6 +48,8 @@ module Checkoff
|
|
48
48
|
'no_value' => CustomFieldVariant::NoValue,
|
49
49
|
'is_not' => CustomFieldVariant::IsNot,
|
50
50
|
'less_than' => CustomFieldVariant::LessThan,
|
51
|
+
'greater_than' => CustomFieldVariant::GreaterThan,
|
52
|
+
'doesnt_contain_any' => CustomFieldVariant::DoesntContainAny,
|
51
53
|
}.freeze
|
52
54
|
|
53
55
|
def convert_single_custom_field_params(gid, single_custom_field_params)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
module Checkoff
|
4
4
|
module Internal
|
5
5
|
module SearchUrl
|
6
|
+
# https://developers.asana.com/docs/search-tasks-in-a-workspace
|
6
7
|
module CustomFieldVariant
|
7
8
|
# base class for handling different custom_field_#{gid}.variant params
|
8
9
|
class CustomFieldVariant
|
@@ -14,56 +15,67 @@ module Checkoff
|
|
14
15
|
private
|
15
16
|
|
16
17
|
attr_reader :gid, :remaining_params
|
17
|
-
end
|
18
18
|
|
19
|
-
|
20
|
-
class LessThan < CustomFieldVariant
|
21
|
-
def convert
|
22
|
-
max_param = "custom_field_#{gid}.max"
|
19
|
+
def fetch_solo_param(param_name)
|
23
20
|
case remaining_params.keys
|
24
|
-
when [
|
25
|
-
|
21
|
+
when [param_name]
|
22
|
+
param_values = remaining_params.fetch(param_name)
|
23
|
+
unless param_values.length == 1
|
24
|
+
raise "Teach me how to handle these remaining keys for #{param_name}: #{remaining_params}"
|
25
|
+
end
|
26
|
+
|
27
|
+
param_values[0]
|
26
28
|
else
|
27
29
|
raise "Teach me how to handle #{remaining_params}"
|
28
30
|
end
|
29
31
|
end
|
32
|
+
end
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
def
|
34
|
-
|
35
|
-
unless max_values.length == 1
|
36
|
-
raise "Teach me how to handle these remaining keys for #{max_param}: #{remaining_params}"
|
37
|
-
end
|
38
|
-
|
39
|
-
max_value = max_values[0]
|
34
|
+
# custom_field_#{gid}.variant = 'less_than'
|
35
|
+
class LessThan < CustomFieldVariant
|
36
|
+
def convert
|
37
|
+
max_value = fetch_solo_param("custom_field_#{gid}.max")
|
40
38
|
empty_task_selector = []
|
41
39
|
[{ "custom_fields.#{gid}.less_than" => max_value }, empty_task_selector]
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
43
|
+
# custom_field_#{gid}.variant = 'greater_than'
|
44
|
+
class GreaterThan < CustomFieldVariant
|
45
|
+
def convert
|
46
|
+
max_value = fetch_solo_param("custom_field_#{gid}.min")
|
47
|
+
empty_task_selector = []
|
48
|
+
[{ "custom_fields.#{gid}.greater_than" => max_value }, empty_task_selector]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# This is used in the UI for select fields
|
53
|
+
#
|
45
54
|
# custom_field_#{gid}.variant = 'is_not'
|
46
55
|
class IsNot < CustomFieldVariant
|
47
56
|
def convert
|
48
|
-
|
49
|
-
when ["custom_field_#{gid}.selected_options"]
|
50
|
-
convert_single_custom_field_is_not_params_selected_options
|
51
|
-
else
|
52
|
-
raise "Teach me how to handle #{remaining_params}"
|
53
|
-
end
|
54
|
-
end
|
57
|
+
selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
|
55
58
|
|
56
|
-
|
59
|
+
[{ "custom_fields.#{gid}.is_set" => 'true' },
|
60
|
+
['not',
|
61
|
+
['custom_field_gid_value_contains_any_gid',
|
62
|
+
gid,
|
63
|
+
selected_options]]]
|
64
|
+
end
|
65
|
+
end
|
57
66
|
|
58
|
-
|
59
|
-
|
60
|
-
|
67
|
+
# This is used in the UI for multi-select fields
|
68
|
+
#
|
69
|
+
# custom_field_#{gid}.variant = 'doesnt_contain_any'
|
70
|
+
class DoesntContainAny < CustomFieldVariant
|
71
|
+
def convert
|
72
|
+
selected_options = fetch_solo_param("custom_field_#{gid}.selected_options").split('~')
|
61
73
|
|
62
74
|
[{ "custom_fields.#{gid}.is_set" => 'true' },
|
63
75
|
['not',
|
64
76
|
['custom_field_gid_value_contains_any_gid',
|
65
77
|
gid,
|
66
|
-
selected_options
|
78
|
+
selected_options]]]
|
67
79
|
end
|
68
80
|
end
|
69
81
|
|
@@ -105,24 +105,40 @@ module Checkoff
|
|
105
105
|
end
|
106
106
|
|
107
107
|
matched_custom_field = custom_fields.find { |data| data.fetch('gid') == custom_field_gid }
|
108
|
-
|
108
|
+
if matched_custom_field.nil?
|
109
|
+
raise "Could not find custom field with gid #{custom_field_gid} in #{task.gid} with #{custom_fields}"
|
110
|
+
end
|
109
111
|
|
110
112
|
matched_custom_field
|
111
113
|
end
|
112
114
|
|
113
|
-
def
|
114
|
-
|
115
|
+
def pull_enum_values(custom_field)
|
116
|
+
resource_subtype = custom_field.fetch('resource_subtype')
|
117
|
+
case resource_subtype
|
118
|
+
when 'enum'
|
119
|
+
[custom_field.fetch('enum_value')]
|
120
|
+
when 'multi_enum'
|
121
|
+
custom_field.fetch('multi_enum_values')
|
122
|
+
else
|
123
|
+
raise "Teach me how to handle resource_subtype #{resource_subtype}"
|
124
|
+
end
|
125
|
+
end
|
115
126
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
end
|
127
|
+
def find_gids(custom_field, enum_value)
|
128
|
+
if enum_value.nil?
|
129
|
+
[]
|
130
|
+
else
|
131
|
+
raise "Unexpected enabled value on custom field: #{custom_field}" if enum_value.fetch('enabled') == false
|
122
132
|
|
123
|
-
|
133
|
+
[enum_value.fetch('gid')]
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def pull_custom_field_values_gids(task, custom_field_gid)
|
138
|
+
custom_field = pull_custom_field_or_raise(task, custom_field_gid)
|
139
|
+
pull_enum_values(custom_field).flat_map do |enum_value|
|
140
|
+
find_gids(custom_field, enum_value)
|
124
141
|
end
|
125
|
-
actual_custom_field_values_gids
|
126
142
|
end
|
127
143
|
end
|
128
144
|
|
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.24.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-01-
|
11
|
+
date: 2023-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|