Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support sorting tasks based on file name and task description #407

Closed
wenlzhang opened this issue Aug 12, 2021 · 5 comments
Closed

Support sorting tasks based on file name and task description #407

wenlzhang opened this issue Aug 12, 2021 · 5 comments
Assignees
Labels
feature-request New feature or request.
Projects
Milestone

Comments

@wenlzhang
Copy link

It would be great if one can sort tasks based on file name and tasks, e.g., task descriptions.

This request can also be seen from the following comment and the related issue.

#46 (comment)

First, I may query all tasks from files within a folder with something like:

dv.taskList(dv.pages('"Daily note"')
	.file.tasks
	.where(t => !t.completed)
	)

This lists all uncompleted tasks from files within the folder Daily note. However, I am not sure how are the task files sorted. Therefore, I would like the tasks to be sorted based on the file name where they come from, e.g. Note A, Note B, Note C, etc. Each of such a note/file consists of a series of uncompleted tasks.

I tried the following options (without knowing if the syntax is correct or not :-(, however), but neither of them worked for me.

dv.taskList(dv.pages('"120-Daily note"')
	.file.tasks
	.where(t => !t.completed)
	.sort(p => p.file.name, 'asc')
	)
dv.taskList(dv.pages('"120-Daily note"')
	.file.tasks
	.where(t => !t.completed)
	.sort(t => t.file.name, 'asc')
	)

Of course, it would be great if the tasks from individual files/notes can also be somehow sorted, e.g., based on task description.

@blacksmithgu
Copy link
Owner

I'm going to add a more general dv.taskGroup (or something similar) which takes in a list-of-lists, which you can use the standard data array operations on to get exactly your desiring ordering.

@blacksmithgu blacksmithgu added this to the 0.4.6 milestone Aug 13, 2021
@sheeley sheeley added this to To do in Tasks Aug 25, 2021
@blacksmithgu blacksmithgu moved this from To do to In progress in Tasks Aug 25, 2021
@blacksmithgu blacksmithgu moved this from In progress to To do in Tasks Aug 25, 2021
@sheeley sheeley moved this from To do to In progress in Tasks Sep 1, 2021
@blacksmithgu blacksmithgu modified the milestones: 0.4.6, 0.5.0 Sep 9, 2021
@sheeley
Copy link
Contributor

sheeley commented Sep 21, 2021

This should be handled as of #452, please let me know if I've missed something!

@sheeley sheeley closed this as completed Sep 21, 2021
Tasks automation moved this from In progress to Done Sep 21, 2021
@TangentFoxy
Copy link

TangentFoxy commented Sep 24, 2022

I'm going to add a more general dv.taskGroup (or something similar) which takes in a list-of-lists, which you can use the standard data array operations on to get exactly your desiring ordering.

There appears to be no dv.taskGroup in the documentation (I'm looking here).

I also tried using sort before the task selection, but that doesn't do anything different.
dv.taskList(dv.pages().sort(p => p.file.name, 'asc').file.tasks.where(t => !t.completed), true)

@AB1908
Copy link
Collaborator

AB1908 commented Oct 8, 2022

@TangentFoxy did you want to sort the tasks by which file they occur in?

@jackreid
Copy link

jackreid commented Dec 13, 2022

Just wanted to voice that, like @TangentFoxy, I would like to use dataviewjs to sort my taskList by the file that they occur in but cannot find any documentation for dv.taskGroup that was supposedly added.

Specifically, I would like to replicate the functionality of this DQL using dataviewjs:

TASK
FROM #tasks
WHERE !completed
GROUP BY file.link
SORT rows.file.date ASC

The following does not impact the order when 'desc' is changed to 'asc' or vice versa:

dv.taskList(dv.pages("#note").sort(p => p.file.name, 'desc').file.tasks
.where(t => !t.completed
))

The following return an evaluation error:

dv.taskList(dv.pages("#note").file.tasks
.where(t => !t.completed
).sort(t => t.file.name, 'asc'))
dv.taskList(dv.pages("#note").file.tasks
.where(t => !t.completed
)).sort(t => t.file.name, 'asc')

Apologies if I am overlooking something obvious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
Tasks
Done
Development

No branches or pull requests

7 participants