checkoff 0.31.0 → 0.33.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/lib/checkoff/my_tasks.rb +19 -4
- data/lib/checkoff/sections.rb +14 -11
- data/lib/checkoff/subtasks.rb +2 -1
- 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: 7ed5d24d3a8427823475fd7d78e6eacc21a64c4175426ae364f71afbf620397a
|
4
|
+
data.tar.gz: f939dfe4c84a35d9676031109ac8e228909f6513e8e84c359554cea358f657a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e5fec3e7e8f37f9ce62d51886267c8a255f9f74da2be5d0136001eb22a95abfd7aacb7c450a8a6fa33ff0b6dc1c8ded7ce36c309237f7c9f8ca9ce5a6a64a9c
|
7
|
+
data.tar.gz: 6f55722a42e2b2e3843b28c8e8bbdcd919463b704fb0e8504576fa7af57f50858d6227da357d5ea87a0f641c023c3c78632743b01d8417d4623962a3b1203b1c
|
data/Gemfile.lock
CHANGED
data/lib/checkoff/my_tasks.rb
CHANGED
@@ -15,8 +15,11 @@ module Checkoff
|
|
15
15
|
attr_reader :projects
|
16
16
|
|
17
17
|
def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
|
18
|
-
|
18
|
+
client: Checkoff::Clients.new(config: config).client,
|
19
|
+
projects: Checkoff::Projects.new(config: config,
|
20
|
+
client: client))
|
19
21
|
@config = config
|
22
|
+
@client = client
|
20
23
|
@projects = projects
|
21
24
|
end
|
22
25
|
|
@@ -27,20 +30,32 @@ module Checkoff
|
|
27
30
|
raw_tasks = projects.tasks_from_project(project,
|
28
31
|
extra_fields: extra_fields + ['assignee_section.name'])
|
29
32
|
active_tasks = projects.active_tasks(raw_tasks)
|
30
|
-
by_my_tasks_section(active_tasks)
|
33
|
+
by_my_tasks_section(active_tasks, project.gid)
|
34
|
+
end
|
35
|
+
|
36
|
+
def section_key(name)
|
37
|
+
return nil if name == 'Recently assigned'
|
38
|
+
|
39
|
+
name
|
31
40
|
end
|
32
41
|
|
33
42
|
# Given a list of tasks in 'My Tasks', pull a Hash of tasks with
|
34
43
|
# section name -> task list
|
35
|
-
def by_my_tasks_section(tasks)
|
44
|
+
def by_my_tasks_section(tasks, project_gid)
|
36
45
|
by_section = {}
|
46
|
+
sections = client.sections.get_sections_for_project(project_gid: project_gid)
|
47
|
+
sections.each { |section| by_section[section_key(section.name)] = [] }
|
37
48
|
tasks.each do |task|
|
38
49
|
assignee_section = task.assignee_section
|
39
|
-
current_section = assignee_section.name
|
50
|
+
current_section = section_key(assignee_section.name)
|
40
51
|
by_section[current_section] ||= []
|
41
52
|
by_section[current_section] << task
|
42
53
|
end
|
43
54
|
by_section
|
44
55
|
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
attr_reader :client
|
45
60
|
end
|
46
61
|
end
|
data/lib/checkoff/sections.rb
CHANGED
@@ -26,7 +26,7 @@ module Checkoff
|
|
26
26
|
time: Time)
|
27
27
|
@projects = projects
|
28
28
|
@workspaces = workspaces
|
29
|
-
@my_tasks = Checkoff::MyTasks.new(config: config, projects: projects)
|
29
|
+
@my_tasks = Checkoff::MyTasks.new(config: config, projects: projects, client: client)
|
30
30
|
@client = client
|
31
31
|
@time = time
|
32
32
|
end
|
@@ -89,19 +89,24 @@ module Checkoff
|
|
89
89
|
# Given a project object, pull all tasks, then provide a Hash of
|
90
90
|
# tasks with section name -> task list of the uncompleted tasks
|
91
91
|
def tasks_by_section_for_project(project, extra_fields: [])
|
92
|
-
# print("project: #{project}")
|
93
92
|
raw_tasks = projects.tasks_from_project(project, extra_fields: extra_fields)
|
94
|
-
# print("raw_tasks[0]: #{raw_tasks[0]}")
|
95
93
|
active_tasks = projects.active_tasks(raw_tasks)
|
96
94
|
by_section(active_tasks, project.gid)
|
97
95
|
end
|
98
96
|
|
97
|
+
def section_key(name)
|
98
|
+
inbox_section_names = ['(no section)', 'Untitled section', 'Inbox']
|
99
|
+
return nil if inbox_section_names.include?(name)
|
100
|
+
|
101
|
+
name
|
102
|
+
end
|
103
|
+
|
99
104
|
# Given a list of tasks, pull a Hash of tasks with section name -> task list
|
100
105
|
def by_section(tasks, project_gid)
|
101
106
|
by_section = {}
|
102
|
-
|
103
|
-
|
104
|
-
|
107
|
+
sections = client.sections.get_sections_for_project(project_gid: project_gid)
|
108
|
+
sections.each { |section| by_section[section_key(section.name)] = [] }
|
109
|
+
tasks.each { |task| file_task_by_section(by_section, task, project_gid) }
|
105
110
|
by_section
|
106
111
|
end
|
107
112
|
cache_method :by_section, LONG_CACHE_TIME
|
@@ -110,11 +115,9 @@ module Checkoff
|
|
110
115
|
membership = task.memberships.find { |m| m['project']['gid'] == project_gid }
|
111
116
|
raise "Could not find task in project_gid #{project_gid}: #{task}" if membership.nil?
|
112
117
|
|
113
|
-
current_section = membership['section']['name']
|
114
|
-
|
115
|
-
|
116
|
-
by_section[current_section] ||= []
|
117
|
-
by_section[current_section] << task
|
118
|
+
current_section = section_key(membership['section']['name'])
|
119
|
+
|
120
|
+
by_section.fetch(current_section) << task
|
118
121
|
end
|
119
122
|
|
120
123
|
def project_or_raise(workspace_name, project_name)
|
data/lib/checkoff/subtasks.rb
CHANGED
@@ -61,9 +61,10 @@ module Checkoff
|
|
61
61
|
def file_task_by_section(current_section, by_section, task)
|
62
62
|
if subtask_section?(task)
|
63
63
|
current_section = task.name
|
64
|
+
raise "More than one section named #{task.name}" if by_section.key? task.name
|
65
|
+
|
64
66
|
by_section[current_section] = []
|
65
67
|
else
|
66
|
-
by_section[current_section] ||= []
|
67
68
|
by_section[current_section] << task
|
68
69
|
end
|
69
70
|
[current_section, by_section]
|
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.33.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-02
|
11
|
+
date: 2023-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|