illiteratewriter / todoist-rs

14 stars 2 forks source link

fix(Task, Section, Project): additional integer overflows for order #3

Closed jeffglover closed 1 month ago

jeffglover commented 1 month ago

I hope it's ok to go straight for a pull request, with your last commit as a guide.

I am still getting invalid range errors, this time negative numbers. Using jq, I filtered out unique order from tasks, sections, and projects. Because order in one of my tasks is 2147483647, which happens to be max signed int 32. I figured i32 would be a safe choice.

Tasks

curl --header "Authorization: Bearer <API_TOKEN>" https://api.todoist.com/rest/v2/tasks | jq -c 'sort_by(.order) | unique_by(.order) | [.[].order]'

[-9,-8,-7,-6,-5,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,24,25,2147483645,2147483646,2147483647]

Sections

curl --header "Authorization: Bearer <API_TOKEN>" https://api.todoist.com/rest/v2/sections | jq -c 'sort_by(.order) | unique_by(.order) | [.[].order]'

[-1,0,1,2,3,4,5,6]

Projects

Even though the numbers would fit, I figured for consistency, order for Project should be modified as well.

curl --header "Authorization: Bearer <API_TOKEN>" https://api.todoist.com/rest/v2/projects | jq -c 'sort_by(.order) | unique_by(.order) | [.[].order]'

[0,3,4,5,6,7,8,9,10]

Everything seems to be working. Now that I can run it, I like what I see so far!

illiteratewriter commented 1 month ago

LGTM