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

DataviewJS listing tasks with tags will pick up "tags" within URLs #2493

Open
mikedidomizio opened this issue Dec 6, 2024 · 0 comments
Open
Labels
bug Something isn't working.

Comments

@mikedidomizio
Copy link

What happened?

Description

I have a number of tasks with tags

I wanted a dataviewjs table to list and sort all tasks, that are incomplete and group by tag.
I used ChatGPT to whip something up and it generated the following:

let tagCounts = {};

// Loop through all pages in the vault
for (let page of dv.pages()) {
    if (page.file.tasks) {
        for (let task of page.file.tasks) {
            // Only consider not completed tasks
            if (!task.completed && task.tags) {
                for (let tag of task.tags) {
                    tagCounts[tag] = (tagCounts[tag] || 0) + 1;
                }
            }
        }
    }
}

// Convert the object to an array of [tag, count] pairs and sort by count (descending)
let sortedTags = Object.entries(tagCounts).sort((a, b) => b[1] - a[1]);

// Render the results as a table
dv.table(["Tag", "Count"], sortedTags);

The problem I have is that I had a link in a markdown file that had #inbox in the URL like this:

- [ ] [REDACTED](https://REDACTED/#inbox) ➕ 2024-05-10

Looking at the code ChatGPT generated, it doesn't seem incorrect. I can verify via console.log that the dv object(s) are picking up the above #inbox.

How to reproduce

  • Create a markdown file with the above task/tag
  • Use the dataviewjs code snippet above

Expected Result

Dataviewjs doesn't pick it up ✅
Obsidian Search doesn't pick it up ✅

Actual Result

Dataviewjs picks the tag up ❌
Obsidian Search doesn't pick it up ✅

DQL

No response

JS

No response

Dataview Version

0.5.66

Obsidian Version

1.7.7

OS

MacOS

@mikedidomizio mikedidomizio added the bug Something isn't working. label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

1 participant