checkoff 0.46.0 → 0.47.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 +2 -2
- data/lib/checkoff/internal/search_url/date_param_converter.rb +4 -2
- data/lib/checkoff/internal/task_selector_evaluator.rb +40 -0
- data/lib/checkoff/my_tasks.rb +21 -2
- data/lib/checkoff/projects.rb +4 -2
- data/lib/checkoff/sections.rb +15 -6
- 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: ceda0651cbf579c86f81e93c887531c64a3147519488daf1be6d11491e896bf9
|
4
|
+
data.tar.gz: 17c109b638773681a63b209ab74b82f6de4bba2962b2475ceac8305c426f14aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 183735480d70aef2cfb4a23bf0b37e18df9360208286bd16ff5fbbfe07dcb5447918cd0400604cb95cb0720b11322effee388af4c9b3832d92b06b6b5a400ac6
|
7
|
+
data.tar.gz: 3c93bb2a2182f53960e763fdab615741be3ec9fc7cfc383c907ef6adf09351fd4b000be9869d8bec37b2cf221c3d41aa52dc6714ed398fad11c90dfc558e95e1
|
data/Gemfile.lock
CHANGED
data/config/definitions.rb
CHANGED
@@ -83,7 +83,7 @@
|
|
83
83
|
# # just because another object it is associated with (e.g. a subtask)
|
84
84
|
# # is modified. Actions that count as modifying the task include
|
85
85
|
# # assigning, renaming, completing, and adding stories.
|
86
|
-
# # @return [
|
86
|
+
# # @return [Enumerable<Asana::Resources::Task>]
|
87
87
|
# def find_all(assignee: nil, workspace: nil, project: nil, section: nil,
|
88
88
|
# tag: nil, user_task_list: nil, completed_since: nil,
|
89
89
|
# modified_since: nil, per_page: 20, options: {}); end
|
@@ -106,7 +106,7 @@
|
|
106
106
|
# class Section
|
107
107
|
# # @param project_gid [String]
|
108
108
|
# # @return [Enumerable<Asana::Resources::Section>]
|
109
|
-
# def get_sections_for_project(
|
109
|
+
# def get_sections_for_project(project_gid:, options: {}); end
|
110
110
|
# end
|
111
111
|
# class Project
|
112
112
|
# # Returns the compact project records for all projects in the workspace.
|
@@ -48,9 +48,11 @@ module Checkoff
|
|
48
48
|
|
49
49
|
# @return [void]
|
50
50
|
def validate_due_date_through_next!
|
51
|
-
|
51
|
+
due_date_operators = date_url_params.fetch('due_date.operator')
|
52
52
|
|
53
|
-
|
53
|
+
return if due_date_operators == ['through_next']
|
54
|
+
|
55
|
+
raise "Teach me how to handle date mode: #{due_date_operators}."
|
54
56
|
end
|
55
57
|
|
56
58
|
# @return [Hash<String, Array<String>>]
|
@@ -32,6 +32,17 @@ module Checkoff
|
|
32
32
|
object.is_a?(Array) && !object.empty? && [fn_name, fn_name.to_s].include?(object[0])
|
33
33
|
end
|
34
34
|
|
35
|
+
# @param task [Asana::Resources::Task]
|
36
|
+
# @param field_name [Symbol]
|
37
|
+
#
|
38
|
+
# @sg-ignore
|
39
|
+
# @return [Date, nil]
|
40
|
+
def pull_date_field_by_name_or_raise(task, field_name)
|
41
|
+
raise "Teach me how to handle field #{field_name}" unless field_name == :modified_at
|
42
|
+
|
43
|
+
task.modified_at
|
44
|
+
end
|
45
|
+
|
35
46
|
# @sg-ignore
|
36
47
|
# @param task [Asana::Resources::Task]
|
37
48
|
# @param custom_field_gid [String]
|
@@ -330,6 +341,34 @@ module Checkoff
|
|
330
341
|
end
|
331
342
|
end
|
332
343
|
|
344
|
+
# :field_less_than_n_days_ago
|
345
|
+
class FieldLessThanNDaysAgoFunctionEvaluator < FunctionEvaluator
|
346
|
+
FUNCTION_NAME = :field_less_than_n_days_ago
|
347
|
+
|
348
|
+
def matches?
|
349
|
+
fn?(task_selector, FUNCTION_NAME)
|
350
|
+
end
|
351
|
+
|
352
|
+
def evaluate_arg?(_index)
|
353
|
+
false
|
354
|
+
end
|
355
|
+
|
356
|
+
# @param task [Asana::Resources::Task]
|
357
|
+
# @param field_name [Symbol]
|
358
|
+
# @param num_days [Integer]
|
359
|
+
#
|
360
|
+
# @return [Boolean]
|
361
|
+
def evaluate(task, field_name, num_days)
|
362
|
+
time = pull_date_field_by_name_or_raise(task, field_name)
|
363
|
+
|
364
|
+
return false if time.nil?
|
365
|
+
|
366
|
+
n_days_ago = (Time.now - (num_days * 24 * 60 * 60))
|
367
|
+
# @sg-ignore
|
368
|
+
time < n_days_ago
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
333
372
|
# :custom_field_less_than_n_days_from_now function
|
334
373
|
class CustomFieldLessThanNDaysFromNowFunctionEvaluator < FunctionEvaluator
|
335
374
|
FUNCTION_NAME = :custom_field_less_than_n_days_from_now
|
@@ -427,6 +466,7 @@ module Checkoff
|
|
427
466
|
Checkoff::TaskSelectorClasses::AndFunctionEvaluator,
|
428
467
|
Checkoff::TaskSelectorClasses::DuePFunctionEvaluator,
|
429
468
|
Checkoff::TaskSelectorClasses::DueDateSetPFunctionEvaluator,
|
469
|
+
Checkoff::TaskSelectorClasses::FieldLessThanNDaysAgoFunctionEvaluator,
|
430
470
|
Checkoff::TaskSelectorClasses::CustomFieldLessThanNDaysFromNowFunctionEvaluator,
|
431
471
|
Checkoff::TaskSelectorClasses::CustomFieldGreaterThanOrEqualToNDaysFromNowFunctionEvaluator,
|
432
472
|
Checkoff::TaskSelectorClasses::StringLiteralEvaluator,
|
data/lib/checkoff/my_tasks.rb
CHANGED
@@ -12,8 +12,12 @@ module Checkoff
|
|
12
12
|
LONG_CACHE_TIME = MINUTE * 15
|
13
13
|
SHORT_CACHE_TIME = MINUTE * 5
|
14
14
|
|
15
|
+
# @return [Checkoff::Projects]
|
15
16
|
attr_reader :projects
|
16
17
|
|
18
|
+
# @param config [Hash<Symbol, Object>]
|
19
|
+
# @param client [Asana::Client]
|
20
|
+
# @param projects [Checkoff::Projects]
|
17
21
|
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
18
22
|
client: Checkoff::Clients.new(config: config).client,
|
19
23
|
projects: Checkoff::Projects.new(config: config,
|
@@ -26,13 +30,23 @@ module Checkoff
|
|
26
30
|
# Given a 'My Tasks' project object, pull all tasks, then provide
|
27
31
|
# a Hash of tasks with section name -> task list of the
|
28
32
|
# uncompleted tasks.
|
29
|
-
|
33
|
+
#
|
34
|
+
# @param project [Asana::Resources::Project]
|
35
|
+
# @param only_uncompleted [Boolean]
|
36
|
+
# @param extra_fields [Array<String>]
|
37
|
+
# @return [Hash<String, Enumerable<Asana::Resources::Task>>]
|
38
|
+
def tasks_by_section_for_my_tasks(project,
|
39
|
+
only_uncompleted: true,
|
40
|
+
extra_fields: [])
|
30
41
|
raw_tasks = projects.tasks_from_project(project,
|
42
|
+
only_uncompleted: only_uncompleted,
|
31
43
|
extra_fields: extra_fields + ['assignee_section.name'])
|
32
44
|
active_tasks = projects.active_tasks(raw_tasks)
|
33
45
|
by_my_tasks_section(active_tasks, project.gid)
|
34
46
|
end
|
35
47
|
|
48
|
+
# @param name [String]
|
49
|
+
# @return [String, nil]
|
36
50
|
def section_key(name)
|
37
51
|
return nil if name == 'Recently assigned'
|
38
52
|
|
@@ -41,10 +55,14 @@ module Checkoff
|
|
41
55
|
|
42
56
|
# Given a list of tasks in 'My Tasks', pull a Hash of tasks with
|
43
57
|
# section name -> task list
|
58
|
+
#
|
59
|
+
# @param tasks [Enumerable<Asana::Resources::Task>]
|
60
|
+
# @param project_gid [String]
|
61
|
+
# @return [Hash<String, Enumerable<Asana::Resources::Task>>]
|
44
62
|
def by_my_tasks_section(tasks, project_gid)
|
45
63
|
by_section = {}
|
46
64
|
sections = client.sections.get_sections_for_project(project_gid: project_gid)
|
47
|
-
sections.
|
65
|
+
sections.each_entry { |section| by_section[section_key(section.name)] = [] }
|
48
66
|
tasks.each do |task|
|
49
67
|
assignee_section = task.assignee_section
|
50
68
|
current_section = section_key(assignee_section.name)
|
@@ -56,6 +74,7 @@ module Checkoff
|
|
56
74
|
|
57
75
|
private
|
58
76
|
|
77
|
+
# @return [Asana::Client]
|
59
78
|
attr_reader :client
|
60
79
|
end
|
61
80
|
end
|
data/lib/checkoff/projects.rb
CHANGED
@@ -91,12 +91,14 @@ module Checkoff
|
|
91
91
|
# @param [Boolean] only_uncompleted
|
92
92
|
# @param [Array<String>] extra_fields
|
93
93
|
# @return [Enumerable<Asana::Resources::Task>]
|
94
|
-
def tasks_from_project(project,
|
94
|
+
def tasks_from_project(project,
|
95
|
+
only_uncompleted: true,
|
96
|
+
extra_fields: [])
|
95
97
|
options = task_options
|
96
98
|
options[:completed_since] = '9999-12-01' if only_uncompleted
|
97
99
|
options[:project] = project.gid
|
98
100
|
options[:options][:fields] += extra_fields
|
99
|
-
client.tasks.find_all(**options)
|
101
|
+
client.tasks.find_all(**options)
|
100
102
|
end
|
101
103
|
cache_method :tasks_from_project, SHORT_CACHE_TIME
|
102
104
|
|
data/lib/checkoff/sections.rb
CHANGED
@@ -65,17 +65,21 @@ module Checkoff
|
|
65
65
|
# tasks with section name -> task list of the uncompleted tasks
|
66
66
|
# @param workspace_name [String]
|
67
67
|
# @param project_name [String, Symbol]
|
68
|
+
# @param only_uncompleted [Boolean]
|
68
69
|
# @param extra_fields [Array<String>]
|
69
70
|
# @return [Hash{[String, nil] => Enumerable<Asana::Resources::Task>}]
|
70
|
-
def tasks_by_section(workspace_name,
|
71
|
+
def tasks_by_section(workspace_name,
|
72
|
+
project_name,
|
73
|
+
only_uncompleted: true,
|
74
|
+
extra_fields: [])
|
71
75
|
raise ArgumentError, 'Provided nil workspace name' if workspace_name.nil?
|
72
76
|
raise ArgumentError, 'Provided nil project name' if project_name.nil?
|
73
77
|
|
74
78
|
project = project_or_raise(workspace_name, project_name)
|
75
79
|
if project_name == :my_tasks
|
76
|
-
my_tasks.tasks_by_section_for_my_tasks(project, extra_fields: extra_fields)
|
80
|
+
my_tasks.tasks_by_section_for_my_tasks(project, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
|
77
81
|
else
|
78
|
-
tasks_by_section_for_project(project, extra_fields: extra_fields)
|
82
|
+
tasks_by_section_for_project(project, only_uncompleted: only_uncompleted, extra_fields: extra_fields)
|
79
83
|
end
|
80
84
|
end
|
81
85
|
|
@@ -140,10 +144,15 @@ module Checkoff
|
|
140
144
|
# Given a project object, pull all tasks, then provide a Hash of
|
141
145
|
# tasks with section name -> task list of the uncompleted tasks
|
142
146
|
# @param project [Asana::Resources::Project]
|
147
|
+
# @param only_uncompleted [Boolean]
|
143
148
|
# @param extra_fields [Array<String>]
|
144
149
|
# @return [Hash<[String,nil], Enumerable<Asana::Resources::Task>>]
|
145
|
-
def tasks_by_section_for_project(project,
|
146
|
-
|
150
|
+
def tasks_by_section_for_project(project,
|
151
|
+
only_uncompleted: true,
|
152
|
+
extra_fields: [])
|
153
|
+
raw_tasks = projects.tasks_from_project(project,
|
154
|
+
only_uncompleted: only_uncompleted,
|
155
|
+
extra_fields: extra_fields)
|
147
156
|
active_tasks = projects.active_tasks(raw_tasks)
|
148
157
|
by_section(active_tasks, project.gid)
|
149
158
|
end
|
@@ -165,7 +174,7 @@ module Checkoff
|
|
165
174
|
by_section = {}
|
166
175
|
# @sg-ignore
|
167
176
|
sections = client.sections.get_sections_for_project(project_gid: project_gid)
|
168
|
-
sections.
|
177
|
+
sections.each_entry { |section| by_section[section_key(section.name)] = [] }
|
169
178
|
tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
|
170
179
|
by_section
|
171
180
|
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.47.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: 2023-09-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|