jamiebrynes7 / obsidian-todoist-plugin

Materialize Todoist tasks in Obsidian notes
https://jamiebrynes7.github.io/obsidian-todoist-plugin/
MIT License
946 stars 70 forks source link

Tasks from some sub-projects show up but not from other sub-projects #327

Open ahafri opened 4 months ago

ahafri commented 4 months ago

Describe the bug When I have a filter for projects and sub-projects (see below), certain tasks in certain sub-projects appear but not in other sub-projects. It does not seem to be related to the title of the project (e.g., whether it contains characters like ":" or emojis). The same filter parameters appear to work fine in the Todoist application.

The filter used is:

name: Work Today Tasks
filter: "##Work 🎯 & (today | overdue)"
sorting:
   - date
   - priority
group: false

To Reproduce I am not sure how to reproduce it. But one attempt could be:

  1. Create a main project with sub-projects, and tasks in sub-projects.
  2. Create a filter view in the plugin.
  3. See whether the tasks all appear in Obsidian.

Screenshots

image image

Desktop: Mac OSX Sonoma 14.3.1

jamiebrynes7 commented 4 months ago

I'm struggling to reproduce this bug, my initial thought is maybe Todoist isn't actually sending the tasks in the API response.

If you enable debug logging from the plugin settings, the raw request/responses will be logged in the developer console - then we can see which tasks are actually returned by Todoist.

Are you able to reliably reproduce this with that specific query & project setup?

ahafri commented 4 months ago

You're right, Todoist isn't returning those tasks in the API response. Yet the same query works fine in the app proper (i.e., it returns from the sub-projects). I am kind of at a loss.

Is there a way for me to directly test different queries in the console?

jamiebrynes7 commented 4 months ago

There's a very roundabout way by reaching into the internals of the system!

First you need to register a subscription:

const [_, refresh] = app.plugins.plugins['todoist-sync-plugin'].services.todoist.subscribe("##Test", (tasks) => console.log(tasks))

Then call the refresh callback to trigger the API call and then log to the console:

refresh()

This is asynchronous, so the tasks will appear a short while after you press enter

ahafri commented 4 months ago

OK, I just installed the latest plugin version (1.13.0), and the API call now gives me the requested data (it wasn't before, with plugin version 1.11.1). The query retrieved in the console and what's shown in the Obsidian note are in line with one another, so the issue appears to be that the query itself does not return all the tasks that it should, based on the filter (whereas in the Todoist app itself, the same query does).

I think I pinpointed the issue: The plugin (at least for me) appears to fail at retrieving tasks that are in sub-projects of sub-projects:

Here's the plugin:

image

Here's the Todoist app. Notice the additional task ("Email undergrad...") which is under the section "Recruiting" from the "Recruiting and Branding 🆕" project (which itself is under the "Work 🎯" main project):

image

The missing task ("Email undergrad...") is one embedded at two levels of projects: "Work 🎯" > "Set Up Research 🔬" > "Recruiting and Branding 🆕". When I put the very same task one project up (in "Set Up Research 🔬") so it's just one level under the main project, the plugin succeeds at retrieving it.

jamiebrynes7 commented 4 months ago

the API call now gives me the requested data (it wasn't before, with plugin version 1.11.1)

I take this to mean the code snippet I gave you didn't work until you updated? If so, yeah that's expected - sorry I missed you were on an old version! I rewrote the querying backend between those versions 😅

so the issue appears to be that the query itself does not return all the tasks that it should, based on the filter [...] I think I pinpointed the issue: The plugin (at least for me) appears to fail at retrieving tasks that are in sub-projects of sub-projects

This is great - thanks for tracing this down. I'll try and repro this myself, but regardless I'll raise an issue with Todoist (I don't work there and this is just an unofficial plugin) to try and get the API response fixed!

ahafri commented 4 months ago

Ah, that's great! Didn't think about the fact that the issue could be on Todoist's end, but of course, that makes sense. Looking forward to seeing the resolution. (And by the way, I love your plugin; thanks for making it!)

jamiebrynes7 commented 4 months ago

I don't think you'll be able to access this, but for my own future reference - https://get.todoist.help/hc/en-us/requests/831430