Skip to content

Commit

Permalink
fix(aof_tasks): also get tasks without a project
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Mar 30, 2022
1 parent 4dc6699 commit c47791c
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions lua/telescope/_extensions/neorg/find_aof_tasks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,24 @@ local function get_aof_projects()
end

local function get_aof_tasks(aof)
local project_tasks = utils.get_project_tasks()
local aof_projects = get_aof_projects()
local raw_tasks = {}
local tasks_raw = neorg.modules.get_module("core.gtd.queries").get("tasks")
tasks_raw = neorg.modules.get_module("core.gtd.queries").add_metadata(tasks_raw, "task")
local aof_tasks = neorg.modules.get_module("core.gtd.queries").sort_by("area_of_focus", tasks_raw)
aof_tasks = aof_tasks[aof]
local tasks = {}
local highlights = {}
for _, project in ipairs(aof_projects[aof]) do
local pr_tasks = project_tasks[project.uuid]
if pr_tasks and pr_tasks ~= {} then
for _, task in ipairs(pr_tasks) do
table.insert(raw_tasks, task)
end
end
end
for _, task in ipairs(raw_tasks) do
for _, task in ipairs(aof_tasks) do
table.insert(tasks, states[task.state][1] .. task.content)
table.insert(highlights, states[task.state][2])
end
return tasks, highlights
end

local function pick_aof_tasks(aof)
local project_tasks = utils.get_project_tasks()
local aof_projects = get_aof_projects()
local tasks = {}
for _, project in ipairs(aof_projects[aof]) do
local pr_tasks = project_tasks[project.uuid]
if pr_tasks and pr_tasks ~= {} then
for _, task in ipairs(pr_tasks) do
table.insert(tasks, task)
end
end
end
local tasks_raw = neorg.modules.get_module("core.gtd.queries").get("tasks")
tasks_raw = neorg.modules.get_module("core.gtd.queries").add_metadata(tasks_raw, "task")
local aof_tasks = neorg.modules.get_module("core.gtd.queries").sort_by("area_of_focus", tasks_raw)
local tasks = aof_tasks[aof]
local opts = {}

pickers.new(opts, {
Expand Down

0 comments on commit c47791c

Please sign in to comment.