jgauth / MMM-GoogleTasks

21 stars 29 forks source link

Setting maxResults is bugged #4

Open WeredPerson opened 6 years ago

WeredPerson commented 6 years ago

When changing max results it will show more results on page load, however as soon as the list refreshes it will revert back to 10.

z0mb13k1ll commented 3 years ago

this is still an issue. i cannot get it to load more than 10 items. Is the Dev even still around??

GardenOfWyers commented 1 year ago

I know this repo is effectively dead and this is an old issue/thread, but I thought I'd share what I've found looking in to a similar issue I've had where I specified 25 as maxResults, but it only appeared to show 10 or so. There doesn't seem to be any other place where I would be able share this info.

Anyway, the way this module (and all forks of it) uses maxResults is somewhat misleading. For the purpose of the Google API (https://developers.google.com/tasks/reference/rest/v1/tasks/list?apix_params=%7B%22tasklist%22%3A%22MDkzNTYyNjk1MjIwNTc5Mzc1ODM6MDow%22%2C%22maxResults%22%3A20%2C%22pageToken%22%3A%22CgwIl_vunQYQmJWg-gEaEGdwYjZvMTlNY2ZYYUlGQUI%3D%22%7D#query-parameters), maxResults modifies the number of results the tasks API returns per page rather than the amount of tasks it returns in total. The problem becomes when you have nested tasks and more than one page worth of them (however large the maxResults you define is). For example, I have ~50 tasks in the list I'm using with some of them nested and by default the MMM-GoogleTasks module sets the maxResults size to 20. When MMM-GoogleTasks goes to fetch the list, it's grabbing the first page of 20 results that the Google Tasks API returns (which the API just returns 20 tasks period - no guaranteeing that the parent is present for child tasks in those 20 it returns), so there could be 10 of those 20 returned that don't have a parent and are thus not displayed in the module. The code needs to be updated to support that scenario - which may be what you have here.

What would have to happen is that MMM-GoogleTasks would have to do the Google API call and exhaust all of the pages while building a local collection along the way. That way all children are guaranteed to have parents and vice versa (children guaranteed their parents).