checkoff 0.174.0 → 0.176.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 +32 -14
- data/lib/checkoff/internal/task_hashes.rb +31 -10
- data/lib/checkoff/internal/thread_local.rb +21 -0
- data/lib/checkoff/tasks.rb +6 -2
- data/lib/checkoff/version.rb +1 -1
- metadata +3 -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
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Checkoff
|
4
|
+
module Internal
|
5
|
+
# Manage thread lock variables in a block
|
6
|
+
class ThreadLocal
|
7
|
+
# @sg-ignore
|
8
|
+
# @param name [Symbol]
|
9
|
+
# @param value [Object,Boolean]
|
10
|
+
#
|
11
|
+
# @return [Object,Boolean]
|
12
|
+
def with_thread_local_variable(name, value, &block)
|
13
|
+
old_value = Thread.current[name]
|
14
|
+
Thread.current[name] = value
|
15
|
+
block.yield
|
16
|
+
ensure
|
17
|
+
Thread.current[name] = old_value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/checkoff/tasks.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative 'internal/config_loader'
|
|
9
9
|
require_relative 'internal/task_timing'
|
10
10
|
require_relative 'internal/task_hashes'
|
11
11
|
require_relative 'internal/logging'
|
12
|
+
require_relative 'internal/thread_local'
|
12
13
|
require 'asana'
|
13
14
|
|
14
15
|
module Checkoff
|
@@ -116,8 +117,11 @@ module Checkoff
|
|
116
117
|
section_name: :unspecified,
|
117
118
|
only_uncompleted: true,
|
118
119
|
extra_fields: [])
|
119
|
-
|
120
|
-
|
120
|
+
thread_local = Checkoff::Internal::ThreadLocal.new
|
121
|
+
task_gid = thread_local.with_thread_local_variable(:suppress_asana_webhook_watch_creation,
|
122
|
+
true) do
|
123
|
+
gid_for_task(workspace_name, project_name, section_name, task_name)
|
124
|
+
end
|
121
125
|
return nil if task_gid.nil?
|
122
126
|
|
123
127
|
task_by_gid(task_gid, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
|
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
|
@@ -177,6 +177,7 @@ files:
|
|
177
177
|
- lib/checkoff/internal/task_hashes.rb
|
178
178
|
- lib/checkoff/internal/task_selector_evaluator.rb
|
179
179
|
- lib/checkoff/internal/task_timing.rb
|
180
|
+
- lib/checkoff/internal/thread_local.rb
|
180
181
|
- lib/checkoff/monkeypatches/resource_marshalling.rb
|
181
182
|
- lib/checkoff/my_tasks.rb
|
182
183
|
- lib/checkoff/portfolios.rb
|