habitica-scripts icon indicating copy to clipboard operation
habitica-scripts copied to clipboard

Push todos to with duedates to top isn't working sometimes

Open programmerPhysicist opened this issue 2 years ago • 9 comments

When I try to run push-todos-with-duedates-to-top.py, nothing happens. It appears it doesn't rearrange my To Do's. Debugging it with pdb, it appears that it isn't pulling a list of my To Do's at all.

programmerPhysicist avatar Nov 07 '22 05:11 programmerPhysicist

Nothing at all happens? Did you follow the setup instructions in the README? What command-line arguments you are including?

DrStrangepork avatar Nov 07 '22 12:11 DrStrangepork

I did follow the setup instructions.

I ran the python script in a small shell script, which sets the HAB_API_USER and HAB_API_TOKEN environment to the appropriate values, than runs the python script.

programmerPhysicist avatar Nov 09 '22 04:11 programmerPhysicist

If you ran the Python script from within a shell script, you may need to export the HAB_API_USER and HAB_API_TOKEN variables

export HAB_API_USER=<user_id>
export HAB_API_TOKEN=<token>

DrStrangepork avatar Nov 11 '22 00:11 DrStrangepork

I did that in my script. Are you sure the python script works?

programmerPhysicist avatar Nov 12 '22 06:11 programmerPhysicist

Yes, I use it multiple times a day

DrStrangepork avatar Nov 12 '22 06:11 DrStrangepork

Have you tried running the script with the -u and -k arguments instead of relying on environment variables?

DrStrangepork avatar Nov 12 '22 07:11 DrStrangepork

I haven't, yet.

But I did just notice a possible bug in the script. If you look at line 86 (of the latest script at this time), if the baseurl doesn't have an ending '/', it will query a non-existent url, especially if you use the default 'https://habitica.com' value, like I've been using. So if I use the default 'https://habitica.com' + 'tasks/user?type=todos', the url will be 'https://habitica.comtasks/user?type=todos' instead of the intended 'https://habitica.com/tasks/user?type=todos'

programmerPhysicist avatar Nov 12 '22 07:11 programmerPhysicist

Slashes are appended in line 57

args.baseurl += "/api/v3/"

DrStrangepork avatar Nov 12 '22 08:11 DrStrangepork

My bad, I was looking at it late at night. It kinda of works with the -u and -k parameters.

It seems to only work, if the due date is 1 or more days in the past. If the due date is today or further in the future, it doesn't seem to push it to the top.

programmerPhysicist avatar Nov 16 '22 06:11 programmerPhysicist