checkoff 0.173.0 → 0.175.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1673c2678f44633dec96080ac5d922966010a76366fcaf386354b18af8b76b06
4
- data.tar.gz: 553d8638f76827ed472325af3643543fa05f190bda63bf152be949e7daf81235
3
+ metadata.gz: ad196605a8e7b9fb2a14a28040f8f7ee261f13aed5fa6aec8cfde037c174943d
4
+ data.tar.gz: da12083f2d30e975a21464877c8ad47b63c63ea25f05d5599a1944d03c889dbd
5
5
  SHA512:
6
- metadata.gz: ad1531b9807b536e7c7bc937d9cbe236e2aa88b3322877a71dc146ba0e562a3404f1106f8b240e75860b11f21094713b24844cdb370b9cbb87a552889e53f397
7
- data.tar.gz: e664eb216308a74311b23ee76b37f2cb165f886387bd2c30c6581367c53e536afc9d3f21773e9e49b7a2a4e968f65646c2e5746ecb588e6bbfbe26eae8f5ef7f
6
+ metadata.gz: b5a8ff3e8f5598e6392c7528057e7d0077bf95f10cab13faaaff4e09a78be8582d64426f27262f01d2568159ef35213ad2fbc2a4b564144f464a9b112ec5aeac
7
+ data.tar.gz: 968285c9e60e3543ea60a858c0ab845e889b68fe41b2839f37a4163c893ef79449382299c2e413342740419b7812d7f70e2b3cd07d87f613fad7ad80f671e192
data/Gemfile.lock CHANGED
@@ -12,7 +12,7 @@ GIT
12
12
  PATH
13
13
  remote: .
14
14
  specs:
15
- checkoff (0.173.0)
15
+ checkoff (0.175.0)
16
16
  activesupport
17
17
  asana (> 0.10.0)
18
18
  cache_method
@@ -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
@@ -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 = HOUR
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: only_uncompleted,
124
- extra_fields: extra_fields)
125
- t.find { |task| task.name == task_name }
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 :task, SHORT_CACHE_TIME
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:, section_name: :unspecified)
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,
@@ -3,5 +3,5 @@
3
3
  # Command-line and gem client for Asana (unofficial)
4
4
  module Checkoff
5
5
  # Version of library
6
- VERSION = '0.173.0'
6
+ VERSION = '0.175.0'
7
7
  end
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.173.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