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

card.change_pos does not change card's position in the list of cards #322

Open
mals14 opened this issue Aug 25, 2020 · 1 comment
Open

Comments

@mals14
Copy link

mals14 commented Aug 25, 2020

The code does seem to run without error and the json returned by fetch_json function is a valid son with 'pos' changed. Tut no change on the interface. Is this a Trello API issue or py-trello library issue?

On the other hand, card.set_pos("bottom") does work.
But card.set_pos(2) does not work.

Any clues as to why this may be happening?

Thank you.

@kublaikhan
Copy link

Hopefully you found a way around this, but pos is NOT an index value, it's a positive float value that Trello uses when sorting the cards. So cards with a lower pos value go higher in the list, but when you tried to assign 2, it probably remained the lowest value in your list.

By default Trello seems to increment pos by 16384 and then if you insert a card between two cards Trello will assign a pos to the inserted card that is the average of the neighboring cards. One trouble is that if you assign a pos that collides with another card's pos, or if two pos values are too close together then Trello will recalculate the pos values. I've also found that if you assign very large (valid double) values Trello will adjust them to be much smaller. The best way I've found to do a sort is to sort your cards using py-trello and then set pos values in increments of 16384, like Trello does, and use an offset where necessary to make sure you aren't colliding with any existing pos values.

Some details from here: https://news.ycombinator.com/item?id=10957165

In other words, this issue is not a py-trello issue but a Trello API documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants