checkoff 0.191.0 → 0.193.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 +1 -1
- data/config/definitions.rb +12 -0
- data/lib/checkoff/internal/selector_classes/task.rb +1 -1
- data/lib/checkoff/projects.rb +4 -3
- data/lib/checkoff/subtasks.rb +56 -7
- 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: 740a4435d472d0e2034b946c694abd1f40e91bcbf874380ca43de89e82bbdb8e
|
4
|
+
data.tar.gz: 7e41942a46e0dc7ad297a1ce4379fab954a2d3831c223c4a99801cd9567ecb70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c96bb1cc1df2d2874eecb23c8328bb48ea7b5401188dd072dfba815d908965316a9c8062879d61ce6a949b1adfd635db54c6d0a6b436678f0202ad1121072562
|
7
|
+
data.tar.gz: c3b68ef7459b67ccfa436788730b22e01139a12f05d8507b386d3813e0f172e0ff20109ddd2ae2355660c1fe51b9080344e264351a0d79eba1ff6967ece439f7
|
data/Gemfile.lock
CHANGED
data/config/definitions.rb
CHANGED
@@ -54,6 +54,8 @@
|
|
54
54
|
# class Task
|
55
55
|
# # @return [String]
|
56
56
|
# def resource_subtype; end
|
57
|
+
# # @return [Boolean,nil]
|
58
|
+
# def is_rendered_as_separator; end
|
57
59
|
# # @return [String,nil]
|
58
60
|
# def due_at; end
|
59
61
|
# # @return [String,nil]
|
@@ -110,6 +112,16 @@
|
|
110
112
|
# def get_custom_fields_for_workspace(workspace_gid: required("workspace_gid"), options: {}); end
|
111
113
|
# end
|
112
114
|
# class Task
|
115
|
+
# # Get subtasks from a task
|
116
|
+
# #
|
117
|
+
# # @param task_gid [String] (required) The task to operate on.
|
118
|
+
# # @param options [Hash] the request I/O options
|
119
|
+
# # > offset - [str] Offset token. An offset to the next page returned by the API. A pagination request will return an offset token, which can be used as an input parameter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.'
|
120
|
+
# # > limit - [int] Results per page. The number of objects to return per page. The value must be between 1 and 100.
|
121
|
+
# # > opt_fields - [list[str]] Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options.
|
122
|
+
# # > opt_pretty - [bool] Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
|
123
|
+
# # @return [Enumerable<Asana::Resources::Task>]
|
124
|
+
# def get_subtasks_for_task(task_gid: required("task_gid"), options: {}); end
|
113
125
|
# # Returns the complete task record for a single task.
|
114
126
|
# #
|
115
127
|
# # @param id [String] The task to get.
|
data/lib/checkoff/projects.rb
CHANGED
@@ -77,9 +77,10 @@ module Checkoff
|
|
77
77
|
else
|
78
78
|
# @type [Enumerable<Asana::Resources::Project>]
|
79
79
|
ps = projects_by_workspace_name(workspace_name, extra_fields: extra_fields)
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
# @type <Asana::Resources::Project,nil>
|
81
|
+
# @sg-ignore
|
82
|
+
project = ps.find { _1.name == project_name }
|
83
|
+
project_by_gid(project.gid, extra_fields: extra_fields) unless project.nil?
|
83
84
|
end
|
84
85
|
end
|
85
86
|
cache_method :project, REALLY_LONG_CACHE_TIME
|
data/lib/checkoff/subtasks.rb
CHANGED
@@ -7,32 +7,45 @@ require_relative 'projects'
|
|
7
7
|
module Checkoff
|
8
8
|
# Query different subtasks of Asana tasks
|
9
9
|
class Subtasks
|
10
|
+
# @!parse
|
11
|
+
# extend CacheMethod::ClassMethods
|
12
|
+
|
10
13
|
MINUTE = 60
|
11
14
|
LONG_CACHE_TIME = MINUTE * 15
|
12
15
|
SHORT_CACHE_TIME = MINUTE * 5
|
13
16
|
|
14
17
|
extend Forwardable
|
15
18
|
|
19
|
+
# @param config [Hash]
|
20
|
+
# @param projects [Checkoff::Projects]
|
21
|
+
# @param clients [Checkoff::Clients]
|
16
22
|
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
17
|
-
projects: Checkoff::Projects.new(config: config)
|
23
|
+
projects: Checkoff::Projects.new(config: config),
|
24
|
+
clients: Checkoff::Clients.new(config: config))
|
18
25
|
@projects = projects
|
26
|
+
@client = clients.client
|
19
27
|
end
|
20
28
|
|
21
29
|
# True if all subtasks of the task are completed
|
30
|
+
#
|
31
|
+
# @param task [Asana::Resources::Task]
|
22
32
|
def all_subtasks_completed?(task)
|
23
|
-
|
24
|
-
active_subtasks = @projects.active_tasks(
|
33
|
+
rs = raw_subtasks(task)
|
34
|
+
active_subtasks = @projects.active_tasks(rs)
|
25
35
|
# anything left should be a section
|
26
36
|
active_subtasks.all? { |subtask| subtask_section?(subtask) }
|
27
37
|
end
|
28
38
|
|
29
39
|
# pulls a Hash of subtasks broken out by section
|
40
|
+
#
|
30
41
|
# @param tasks [Enumerable<Asana::Resources::Task>]
|
42
|
+
#
|
31
43
|
# @return [Hash<[nil,String], Enumerable<Asana::Resources::Task>>]
|
32
44
|
def by_section(tasks)
|
33
45
|
current_section = nil
|
34
46
|
by_section = { nil => [] }
|
35
47
|
tasks.each do |task|
|
48
|
+
# @sg-ignore
|
36
49
|
current_section, by_section = file_task_by_section(current_section,
|
37
50
|
by_section, task)
|
38
51
|
end
|
@@ -40,26 +53,62 @@ module Checkoff
|
|
40
53
|
end
|
41
54
|
|
42
55
|
# Returns all subtasks, including section headers
|
56
|
+
#
|
57
|
+
# @param task [Asana::Resources::Task]
|
58
|
+
#
|
59
|
+
# @return [Enumerable<Asana::Resources::Task>]
|
43
60
|
def raw_subtasks(task)
|
44
|
-
|
45
|
-
|
46
|
-
|
61
|
+
subtasks_by_gid(task.gid)
|
62
|
+
end
|
63
|
+
cache_method :raw_subtasks, LONG_CACHE_TIME
|
64
|
+
|
65
|
+
# Pull a specific task by GID
|
66
|
+
#
|
67
|
+
# @param task_gid [String]
|
68
|
+
# @param extra_fields [Array<String>]
|
69
|
+
# @param only_uncompleted [Boolean]
|
70
|
+
#
|
71
|
+
# @return [Enumerable<Asana::Resources::Task>]
|
72
|
+
def subtasks_by_gid(task_gid,
|
73
|
+
extra_fields: [],
|
74
|
+
only_uncompleted: true)
|
75
|
+
# @type [Hash]
|
76
|
+
options = projects.task_options.fetch(:options, {})
|
77
|
+
options[:fields] += extra_fields
|
78
|
+
options[:fields] += %w[is_rendered_as_separator]
|
79
|
+
options[:fields].uniq!
|
80
|
+
|
81
|
+
options[:completed_since] = '9999-12-01' if only_uncompleted
|
82
|
+
client.tasks.get_subtasks_for_task(task_gid: task_gid,
|
83
|
+
# per_page: 100, # stub doesn't have this arg available
|
84
|
+
options: options)
|
47
85
|
end
|
48
|
-
cache_method :
|
86
|
+
cache_method :subtasks_by_gid, LONG_CACHE_TIME
|
49
87
|
|
50
88
|
# True if the subtask passed in represents a section in the subtasks
|
51
89
|
#
|
52
90
|
# Note: expect this to be removed in a future version, as Asana is
|
53
91
|
# expected to move to the new-style way of representing sections
|
54
92
|
# as memberships with a separate API within a task.
|
93
|
+
#
|
94
|
+
# @param subtask [Asana::Resources::Task]
|
55
95
|
def subtask_section?(subtask)
|
56
96
|
subtask.is_rendered_as_separator
|
57
97
|
end
|
58
98
|
|
59
99
|
private
|
60
100
|
|
101
|
+
# @return [Checkoff::Projects]
|
61
102
|
attr_reader :projects
|
62
103
|
|
104
|
+
# @return [Asana::Client]
|
105
|
+
attr_reader :client
|
106
|
+
|
107
|
+
# @param current_section [String,nil]
|
108
|
+
# @param by_section [Hash]
|
109
|
+
# @param task [Asana::Resources::Task]
|
110
|
+
#
|
111
|
+
# @return [Array<(String, Hash)>]
|
63
112
|
def file_task_by_section(current_section, by_section, task)
|
64
113
|
if subtask_section?(task)
|
65
114
|
current_section = task.name
|
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.193.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-02-
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|