checkoff 0.175.0 → 0.176.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 +4 -4
- data/lib/checkoff/internal/asana_event_filter.rb +32 -14
- data/lib/checkoff/internal/task_hashes.rb +31 -10
- 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: '009e431ea6abee485edb629966f1412508a9f376750b84ab1db639bb7a252735'
|
4
|
+
data.tar.gz: 439f1735a8f14aa173d9fe7dce52d264e1473ed25b447bc4173055a536a03bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9f2bf902b971678c75fbaa3ed182ddcaeff35c808df829ada02869efb197d91bfa3624d2410ede703b45b8d1e029f4ac105fad4cd1ec8cccc61cd7a71e0bb50
|
7
|
+
data.tar.gz: e21848eb4e6b57b48c661676cac5f33de827f90b378e102e1d4c16a9ceb081f11f5f34aab95c121236697ef5a770bb55e3595d39cabcfc63b4bb617ba96d2e16
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ GIT
|
|
12
12
|
PATH
|
13
13
|
remote: .
|
14
14
|
specs:
|
15
|
-
checkoff (0.
|
15
|
+
checkoff (0.176.0)
|
16
16
|
activesupport
|
17
17
|
asana (> 0.10.0)
|
18
18
|
cache_method
|
@@ -23,7 +23,7 @@ PATH
|
|
23
23
|
GEM
|
24
24
|
remote: https://rubygems.org/
|
25
25
|
specs:
|
26
|
-
activesupport (7.1.
|
26
|
+
activesupport (7.1.3)
|
27
27
|
base64
|
28
28
|
bigdecimal
|
29
29
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -50,7 +50,7 @@ GEM
|
|
50
50
|
concurrent-ruby
|
51
51
|
childprocess (4.1.0)
|
52
52
|
coderay (1.1.3)
|
53
|
-
concurrent-ruby (1.2.
|
53
|
+
concurrent-ruby (1.2.3)
|
54
54
|
connection_pool (2.4.1)
|
55
55
|
crack (0.4.5)
|
56
56
|
rexml
|
@@ -114,7 +114,7 @@ GEM
|
|
114
114
|
mime-types (3.5.1)
|
115
115
|
mime-types-data (~> 3.2015)
|
116
116
|
mime-types-data (3.2023.1205)
|
117
|
-
minitest (5.
|
117
|
+
minitest (5.21.1)
|
118
118
|
minitest-profile (0.0.2)
|
119
119
|
minitest-reporters (1.6.1)
|
120
120
|
ansi
|
@@ -18,12 +18,15 @@ module Checkoff
|
|
18
18
|
|
19
19
|
# @param filters [Array<Hash>, nil] The filters to match against
|
20
20
|
# @param clients [Checkoff::Clients]
|
21
|
+
# @param tasks [Checkoff::Tasks]
|
21
22
|
# @param client [Asana::Client]
|
22
23
|
def initialize(filters:,
|
23
24
|
clients: Checkoff::Clients.new,
|
25
|
+
tasks: Checkoff::Tasks.new,
|
24
26
|
client: clients.client)
|
25
27
|
@filters = filters
|
26
28
|
@client = client
|
29
|
+
@tasks = tasks
|
27
30
|
end
|
28
31
|
|
29
32
|
# @param asana_event [Hash] The event that Asana sent
|
@@ -85,27 +88,42 @@ module Checkoff
|
|
85
88
|
asana_event.fetch('parent', {})['gid'] == value
|
86
89
|
when 'checkoff:resource.gid'
|
87
90
|
asana_event.fetch('resource', {})['gid'] == value
|
91
|
+
when 'checkoff:fetched.section.gid'
|
92
|
+
fields = ['memberships.section.gid', 'assignee', 'assignee_section']
|
93
|
+
task = uncached_fetch_task(key, asana_event, fields)
|
94
|
+
task_data = @tasks.task_to_h(task)
|
95
|
+
task_data.fetch('membership_by_section_gid').keys.include?(value)
|
88
96
|
when 'checkoff:fetched.completed'
|
89
|
-
|
90
|
-
|
91
|
-
resource = asana_event.fetch('resource')
|
92
|
-
# @type [String]
|
93
|
-
resource_type = resource.fetch('resource_type')
|
94
|
-
unless resource_type == 'task'
|
95
|
-
raise "Teach me how to check #{key.inspect} on resource type #{resource_type.inspect}"
|
96
|
-
end
|
97
|
-
|
98
|
-
task_gid = resource.fetch('gid')
|
99
|
-
options = {
|
100
|
-
fields: ['completed_at'],
|
101
|
-
}
|
102
|
-
task = @client.tasks.find_by_id(task_gid, options: options)
|
97
|
+
fields = ['completed_at']
|
98
|
+
task = uncached_fetch_task(key, asana_event, fields)
|
103
99
|
task_completed = !task.completed_at.nil?
|
104
100
|
task_completed == value
|
105
101
|
else
|
106
102
|
raise "Unknown filter key #{key}"
|
107
103
|
end
|
108
104
|
end
|
105
|
+
|
106
|
+
# @param key [String]
|
107
|
+
# @param asana_event [Hash]
|
108
|
+
# @param fields [Array<String>]
|
109
|
+
#
|
110
|
+
# @return [Asana::Resources::Task]
|
111
|
+
def uncached_fetch_task(key, asana_event, fields)
|
112
|
+
# @type [Hash{String => String}]
|
113
|
+
# @sg-ignore
|
114
|
+
resource = asana_event.fetch('resource')
|
115
|
+
# @type [String]
|
116
|
+
resource_type = resource.fetch('resource_type')
|
117
|
+
unless resource_type == 'task'
|
118
|
+
raise "Teach me how to check #{key.inspect} on resource type #{resource_type.inspect}"
|
119
|
+
end
|
120
|
+
|
121
|
+
task_gid = resource.fetch('gid')
|
122
|
+
options = {
|
123
|
+
fields: fields,
|
124
|
+
}
|
125
|
+
@client.tasks.find_by_id(task_gid, options: options)
|
126
|
+
end
|
109
127
|
end
|
110
128
|
end
|
111
129
|
end
|
@@ -12,7 +12,7 @@ module Checkoff
|
|
12
12
|
task_hash = task.to_h
|
13
13
|
task_hash['unwrapped'] = {}
|
14
14
|
unwrap_custom_fields(task_hash)
|
15
|
-
|
15
|
+
unwrap_all_memberships(task_hash)
|
16
16
|
task_hash['task'] = task.name
|
17
17
|
task_hash
|
18
18
|
end
|
@@ -39,15 +39,32 @@ module Checkoff
|
|
39
39
|
task_hash['unwrapped']['custom_fields'] = unwrapped_custom_fields
|
40
40
|
end
|
41
41
|
|
42
|
+
# @param [Hash<String, Hash, Array>] task_hash
|
43
|
+
# @param [Array<Hash>] memberships
|
44
|
+
#
|
45
|
+
# @return [void]
|
46
|
+
def add_user_task_list(task_hash, memberships)
|
47
|
+
return unless task_hash.key? 'assignee_section'
|
48
|
+
|
49
|
+
assignee_section = task_hash.fetch('assignee_section')
|
50
|
+
# @type [Hash]
|
51
|
+
assignee = task_hash.fetch('assignee')
|
52
|
+
memberships << {
|
53
|
+
'section' => assignee_section.dup,
|
54
|
+
'project' => {
|
55
|
+
'gid' => assignee.fetch('gid'),
|
56
|
+
'name' => :my_tasks,
|
57
|
+
},
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
42
61
|
# @param task_hash [Hash]
|
43
62
|
# @param resource [String]
|
63
|
+
# @param memberships [Array<Hash>]
|
44
64
|
# @param key [String]
|
45
65
|
#
|
46
66
|
# @return [void]
|
47
|
-
def
|
48
|
-
# @sg-ignore
|
49
|
-
# @type [Array<Hash>]
|
50
|
-
memberships = task_hash.fetch('memberships', [])
|
67
|
+
def unwrap_memberships(task_hash, memberships, resource, key)
|
51
68
|
# @sg-ignore
|
52
69
|
# @type [Hash]
|
53
70
|
unwrapped = task_hash.fetch('unwrapped')
|
@@ -58,11 +75,15 @@ module Checkoff
|
|
58
75
|
|
59
76
|
# @param task_hash [Hash]
|
60
77
|
# @return [void]
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
78
|
+
def unwrap_all_memberships(task_hash)
|
79
|
+
# @sg-ignore
|
80
|
+
# @type [Array<Hash>]
|
81
|
+
memberships = task_hash.fetch('memberships', []).dup
|
82
|
+
add_user_task_list(task_hash, memberships)
|
83
|
+
unwrap_memberships(task_hash, memberships, 'section', 'gid')
|
84
|
+
unwrap_memberships(task_hash, memberships, 'section', 'name')
|
85
|
+
unwrap_memberships(task_hash, memberships, 'project', 'gid')
|
86
|
+
unwrap_memberships(task_hash, memberships, 'project', 'name')
|
66
87
|
end
|
67
88
|
end
|
68
89
|
end
|
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.176.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: 2024-01-
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|