Replies: 3 comments 5 replies
-
Oooh subqueries eh? I don't think blacksmithgu would implement this in the near future (maybe he will, who knows? 🤷 ). For now, you can nest function calls but it would be a little messy. However, before we get into that, could you give us an example of how you've set your tasks up so we can get an idea of the type of index you have? |
Beta Was this translation helpful? Give feedback.
-
I haven't implemented subqueries yet, which would make this doable in Dataview; it can be achieved in DataviewJS via some manual for loops to collect the information. |
Beta Was this translation helpful? Give feedback.
-
Ok I think I did it using this is assuming you have tasks like that - [ ] this is a new task [done::2022-05-04] or [created::[[2022-05-04]]]
- [ ] this is a new task Also files with the const start = "2022-04-25"
const end = "2022-05-01"
const startDate = new Date(start)
const endDate = new Date(end)
let date_pages = dv.pages().where(x => x.created).where(x => {
const d = new Date(x.created.path)
return x.created && d >= startDate && d <= endDate
})
const all_completed_tasks = dv.pages().where(x => x.created)
.where(x => x.file.tasks.completed.length > 0).map(x => [x, x.file.tasks.where(t => t.completed)])
console.log("all_completed_tasks", all_completed_tasks)
let all_completed_tasks_pairs = []
for(let pair of all_completed_tasks)
{
//console.log(pair)
for(let task of pair[1])
{
all_completed_tasks_pairs.push([task, pair[0]])
}
}
function get_date(pair_array) {
const c = pair_array[1].created
const d = pair_array[1].date
const dt = pair_array[0].done
const created = (c) ? c : d
const done = (dt) ? dv.fileLink(dt.toFormat("yyyy-MM-dd")) : dt
const date = (done) ? done : created
return date
}
all_completed_tasks_pairs = dv.array(all_completed_tasks_pairs).map(x => [x[0], x[1], get_date(x)]).where(x => {
const d = new Date(x[2].path)
return d >= startDate && d <= endDate
})
const group_pages_all = date_pages.groupBy(x => x.created)
dv.table(["Date", "🗒 Notes", "🤝 Meetings", "New Tasks", "Tasks ✅"], group_pages_all.map(g =>
{
//console.log(g)
const num_new_tasks = g.rows.where(x => x.file.tasks.length > 0).length
const tasks_completed = all_completed_tasks_pairs.where(x =>
{
const date = x[2]
if (!date)
return false
return date.path == g.key.path
}).length
//console.log("all tasks", tasks_completed)
const num_meetings = g.rows.where(x => x.category == "meeting").length
const num_notes = g.rows.where(x => x.category != "meeting").length
return [g.key, num_notes, num_meetings, num_new_tasks, tasks_completed]
})) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to create a table. Each row will be a day of the week, and each column will have different metrics about this week. Most of the things I want to track are task related. i.e. how many tasks related to exercise I completed, how many tasks in total. etc...
Let's say I am using the [completed:: 2022-04-28] to signify that they are done on that day (even though the task itself might be saved on a non diary file). How should I do my query on the table? I am not sure this is possible even...My thought was to expand on an idea posted here in the past. The snippet below assumes on each day you have a link to the corresponding week so you use the "where" filtering to only focus on those 7 days. However, I would be interested to do more filters on the individual columns.
The lines below obviously are not working, but maybe they show what I mean to do. So in this case I am getting all the tasks that are completed and are not including the
How it might look like
Also, it would be cool if there is a way to easily get some of the autocomplete there :P
Beta Was this translation helpful? Give feedback.
All reactions