checkoff 0.175.0 → 0.177.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/lib/checkoff/internal/asana_event_filter.rb +33 -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: cbb883b9ef62b4b249ff411385dc4e46c47663f06a139dd30431b00cb959fdf2
|
4
|
+
data.tar.gz: f44e6e678f602f63360f84941886da95407b7f606c04ab0524edcac83ee82f2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f24579a26f058a5e7873d7b6b44cc76d2ab2caa884798e78a2d7e1650bdb3ceb74105126893038f4fe6138a0b5bcf3abbf5adf7f4a30c17df9440ab508ec93c5
|
7
|
+
data.tar.gz: '018b8d5246f00654b788f1014983e5b04bcbe79342562e0e93c0338024d85a485176c185eb1669b21955ac97d56e51b7dbee64205015913b8162e782fd9e23e0'
|
data/Gemfile.lock
CHANGED
@@ -12,7 +12,7 @@ GIT
|
|
12
12
|
PATH
|
13
13
|
remote: .
|
14
14
|
specs:
|
15
|
-
checkoff (0.
|
15
|
+
checkoff (0.177.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,43 @@ 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.project.gid', 'memberships.project.name',
|
93
|
+
'memberships.section.name', 'assignee', 'assignee_section']
|
94
|
+
task = uncached_fetch_task(key, asana_event, fields)
|
95
|
+
task_data = @tasks.task_to_h(task)
|
96
|
+
task_data.fetch('unwrapped').fetch('membership_by_section_gid').keys.include?(value)
|
88
97
|
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)
|
98
|
+
fields = ['completed_at']
|
99
|
+
task = uncached_fetch_task(key, asana_event, fields)
|
103
100
|
task_completed = !task.completed_at.nil?
|
104
101
|
task_completed == value
|
105
102
|
else
|
106
103
|
raise "Unknown filter key #{key}"
|
107
104
|
end
|
108
105
|
end
|
106
|
+
|
107
|
+
# @param key [String]
|
108
|
+
# @param asana_event [Hash]
|
109
|
+
# @param fields [Array<String>]
|
110
|
+
#
|
111
|
+
# @return [Asana::Resources::Task]
|
112
|
+
def uncached_fetch_task(key, asana_event, fields)
|
113
|
+
# @type [Hash{String => String}]
|
114
|
+
# @sg-ignore
|
115
|
+
resource = asana_event.fetch('resource')
|
116
|
+
# @type [String]
|
117
|
+
resource_type = resource.fetch('resource_type')
|
118
|
+
unless resource_type == 'task'
|
119
|
+
raise "Teach me how to check #{key.inspect} on resource type #{resource_type.inspect}"
|
120
|
+
end
|
121
|
+
|
122
|
+
task_gid = resource.fetch('gid')
|
123
|
+
options = {
|
124
|
+
fields: fields,
|
125
|
+
}
|
126
|
+
@client.tasks.find_by_id(task_gid, options: options)
|
127
|
+
end
|
109
128
|
end
|
110
129
|
end
|
111
130
|
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.177.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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|