Giter VIP home page Giter VIP logo

Comments (25)

blacksmithgu avatar blacksmithgu commented on May 23, 2024 9

I have good news and bad news. The good news is this is now possible; the bad news is you need to write a tiny bit of javascript for it:

```dataviewjs
dv.taskList(dv.pages("#projects").file.tasks.where(t => !t.completed));
```

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024 7

This has been on my TODO list forever since it's conceptually simple, my task query implementation is just a hack. Will improve.

from obsidian-dataview.

clotodex avatar clotodex commented on May 23, 2024 2

cool, how can I search in every note in my vault?

With "". dv.pages works like sources in dataview. You need to quote it though - so '""' (single-tick, quote, quote, single-tick)

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

from obsidian-dataview.

channingwalton avatar channingwalton commented on May 23, 2024 1

This would be awesome. Is there a workaround in the meantime?

from obsidian-dataview.

Zyrohex avatar Zyrohex commented on May 23, 2024

This would be a great addition! Hope to see it implemented soon.

from obsidian-dataview.

channingwalton avatar channingwalton commented on May 23, 2024

cool, how can I search in every note in my vault?

from obsidian-dataview.

breach78 avatar breach78 commented on May 23, 2024

I have good news and bad news. The good news is this is now possible; the bad news is you need to write a tiny bit of javascript for it:

```dataviewjs
dv.taskList(dv.pages("#projects").file.tasks.where(t => !t.completed));

Thank you!
Is it possible to list it in modified order?

from obsidian-dataview.

wenlzhang avatar wenlzhang commented on May 23, 2024

Is it possible to sort the tasks based on file name?

from obsidian-dataview.

danielhauck avatar danielhauck commented on May 23, 2024

You mean for tasks that are appearing in a file? Like give me all from "Project X"?

```dataviewjs
const targetPage = "Project X"

 

dv.taskList(
    dv.array(
        dv.page(targetPage).file.tasks
    ).where(t => !t.completed)
)
```

You just need to 'cast' it as a dataview array.

from obsidian-dataview.

wenlzhang avatar wenlzhang commented on May 23, 2024

Thanks for the prompt reply! @danielhauck Sorry for not being clear about what I am trying to achieve. Now I will elaborate it as follows.

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.

I also tried your code, and it gives the following error message:

const targetPage = "Daily note"

dv.taskList(
    dv.array(
        dv.page(targetPage).file.tasks
    ).where(t => !t.completed)
)
Evaluation Error: TypeError: Cannot read property 'file' of undefined
    at eval (eval at <anonymous> (eval at <anonymous> (app://obsidian.md/app.js:1:1212458)), <anonymous>:5:28)
    at DataviewInlineApi.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12129:33)
    at evalInContext (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12129:49)
    at DataviewJSRenderer.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12591:17)
    at Generator.next (<anonymous>)
    at eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:26:71)
    at new Promise (<anonymous>)
    at __awaiter (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:22:12)
    at DataviewJSRenderer.render (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12583:16)
    at DataviewJSRenderer.eval (eval at <anonymous> (app://obsidian.md/app.js:1:1212458), <anonymous>:12578:28)

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

Ah, this is a short-coming of the dv.taskList() implementation; I need to add some configuration to be able to decide how you sort tasks and files. @wenlzhang Would you mind filing an issue with the contents of your comment for tracking?

from obsidian-dataview.

wenlzhang avatar wenlzhang commented on May 23, 2024

That's great news! Looking forward to that! @blacksmithgu This feature request can be found in the following issue:
#407

from obsidian-dataview.

rickybright avatar rickybright commented on May 23, 2024

Is there a way that instead of telling it to look at a file with dv.pages I can have it look at all the files in a folder?

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

You still use dv.pages, just providing the path to the folder: dv.pages('"path/to/folder/"').

from obsidian-dataview.

rickybright avatar rickybright commented on May 23, 2024

Ah, I was just using dv.pages("x/y/z") instead of dv.pages('"x/y/z"').

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

Yay, tasks can now be filtered on completed!

TASK WHERE !completed

You can also do a fair bit other stuff with them, like using the text property (which contains their text), or subtasks (which contains a list of subtasks), and so on!

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

Thanks for @sheeley for implementing this functionality.

from obsidian-dataview.

uwidev avatar uwidev commented on May 23, 2024

Does this functionality extend to DataView Table queries? I'm trying to count all completed tasks onto a table as a proof of concept. I later want to count completed completed tasks per folder. For some reason I can't get any tasks to query.

Here's my query

TABLE length(rows) as "Count Completed Tasks"
FROM "Test"
WHERE completed
Flatten file.tasks
GROUP BY file.folder

Running it barebones and just trying to query completed tasks without fancy groupings doesn't yield any results either. Running the query as a Task rather than a Table works, however.

This is how my notes are set up, in their own folders as follows.
image

from obsidian-dataview.

sheeley avatar sheeley commented on May 23, 2024

The task list and table depend upon different implementations internally. I could see this being interesting.

@blacksmithgu think there should be a task table?

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

@blongty @sheeley The correct move here is to (1) allow FROM statements to select tasks instead of files, and (2) implement task renderering support so that they work automatically in both list views and table views.

This is something @sheeley can look into in the short-medium term if he has time / interest.

from obsidian-dataview.

sheeley avatar sheeley commented on May 23, 2024

@blacksmithgu happy to. Thoughts on the syntax?

  • task table foo, bar from ...
  • table foo, bar as task from
  • table foo, bar from tasks

And for the functionality, would you expect a single task per row? Or would it be possible to render a task per cell? I could see value in the latter.

from obsidian-dataview.

blacksmithgu avatar blacksmithgu commented on May 23, 2024

For the syntax, I'm thinking TABLE foo, bar FROM TASKS <source query>; this particular syntax is mainly because we can extend it easily to support sections and other metadata (FROM SECTIONS ...).

I think the default would be one task per row, allowing "task lists" via a GROUP BY.

from obsidian-dataview.

acetuk avatar acetuk commented on May 23, 2024

Does this functionality extend to DataView Table queries? I'm trying to count all completed tasks onto a table as a proof of concept. I later want to count completed completed tasks per folder. For some reason I can't get any tasks to query.

Here's my query

TABLE length(rows) as "Count Completed Tasks"
FROM "Test"
WHERE completed
Flatten file.tasks
GROUP BY file.folder

Running it barebones and just trying to query completed tasks without fancy groupings doesn't yield any results either. Running the query as a Task rather than a Table works, however.

This is how my notes are set up, in their own folders as follows. image

Did you find a way to count the tasks? I am trying to do the same thing in a standard dataview query where I want to report the number of open tasks and potentially exclude results returned from pages that have no tasks.

from obsidian-dataview.

KaynaL-MT avatar KaynaL-MT commented on May 23, 2024

this also worked for me:

TASK
WHERE task != completed

from obsidian-dataview.

martijnvangils avatar martijnvangils commented on May 23, 2024

task where !completed works as well

from obsidian-dataview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.