checkoff 0.173.0 → 0.175.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 +1 -1
- data/lib/checkoff/internal/thread_local.rb +21 -0
- data/lib/checkoff/tasks.rb +26 -6
- data/lib/checkoff/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad196605a8e7b9fb2a14a28040f8f7ee261f13aed5fa6aec8cfde037c174943d
|
4
|
+
data.tar.gz: da12083f2d30e975a21464877c8ad47b63c63ea25f05d5599a1944d03c889dbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5a8ff3e8f5598e6392c7528057e7d0077bf95f10cab13faaaff4e09a78be8582d64426f27262f01d2568159ef35213ad2fbc2a4b564144f464a9b112ec5aeac
|
7
|
+
data.tar.gz: 968285c9e60e3543ea60a858c0ab845e889b68fe41b2839f37a4163c893ef79449382299c2e413342740419b7812d7f70e2b3cd07d87f613fad7ad80f671e192
|
data/Gemfile.lock
CHANGED
@@ -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
|
@@ -22,7 +23,7 @@ module Checkoff
|
|
22
23
|
MINUTE = 60
|
23
24
|
HOUR = MINUTE * 60
|
24
25
|
DAY = 24 * HOUR
|
25
|
-
REALLY_LONG_CACHE_TIME =
|
26
|
+
REALLY_LONG_CACHE_TIME = MINUTE * 30
|
26
27
|
LONG_CACHE_TIME = MINUTE * 15
|
27
28
|
SHORT_CACHE_TIME = MINUTE * 5
|
28
29
|
|
@@ -116,15 +117,34 @@ module Checkoff
|
|
116
117
|
section_name: :unspecified,
|
117
118
|
only_uncompleted: true,
|
118
119
|
extra_fields: [])
|
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
|
125
|
+
return nil if task_gid.nil?
|
126
|
+
|
127
|
+
task_by_gid(task_gid, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
|
128
|
+
end
|
129
|
+
cache_method :task, LONG_CACHE_TIME
|
130
|
+
|
131
|
+
# @param workspace_name [String]
|
132
|
+
# @param project_name [String, Symbol]
|
133
|
+
# @param section_name [String, nil, Symbol]
|
134
|
+
# @param task_name [String]
|
135
|
+
#
|
136
|
+
# @return [String, nil]
|
137
|
+
# @sg-ignore
|
138
|
+
def gid_for_task(workspace_name, project_name, section_name, task_name)
|
119
139
|
# @sg-ignore
|
120
140
|
t = tasks(workspace_name,
|
121
141
|
project_name,
|
122
142
|
section_name: section_name,
|
123
|
-
only_uncompleted:
|
124
|
-
|
125
|
-
|
143
|
+
only_uncompleted: false)
|
144
|
+
task_for_gid = t.find { |task| task.name == task_name }
|
145
|
+
task_for_gid&.gid
|
126
146
|
end
|
127
|
-
cache_method :
|
147
|
+
cache_method :gid_for_task, REALLY_LONG_CACHE_TIME
|
128
148
|
|
129
149
|
# Pull a specific task by GID
|
130
150
|
#
|
@@ -296,7 +316,7 @@ module Checkoff
|
|
296
316
|
#
|
297
317
|
# @return [Enumerable<Asana::Resources::Task>]
|
298
318
|
def tasks(workspace_name, project_name,
|
299
|
-
only_uncompleted:, extra_fields
|
319
|
+
only_uncompleted:, extra_fields: [], section_name: :unspecified)
|
300
320
|
if section_name == :unspecified
|
301
321
|
project = projects.project_or_raise(workspace_name, project_name)
|
302
322
|
projects.tasks_from_project(project,
|
data/lib/checkoff/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: checkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.175.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vince Broz
|
@@ -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
|