Comment by GlacierFox
5 days ago
Random curious question. I was pondering the kanban backend. How do you store the order of the kanban cards in your database and keep that in sync with what's in the UI?
5 days ago
Random curious question. I was pondering the kanban backend. How do you store the order of the kanban cards in your database and keep that in sync with what's in the UI?
Here is the answer for Trello: each card and list has a field called “pos” which is a number. The initial values are spread out (e.g. 1000, 2000, 3000) and then when you move a card, it takes on the average of the two adjacent cards.
So, if I move the 3rd card to the 2nd position, its “pos” becomes 1500. This means it doesn’t have to constantly renumber the cards -- but, every once and a while, the server does reorder the “pos” fields for a whole list and send the new values down the socket.
I was going to guess linked lists/graphs as that is my goto for extremely flexible local structure. But the sparse array is probably better, relational databases hate linked lists.
Thank you for this, that's so simple and I'd never stumble on that solution which is embarrassing haha. How do you know the Trello internals by the way? You work there?
Yes. I worked there. But it’s described in the API
This concept is called "lexorank"
Well, not quite. Although lexorank is similar, the mothod described above is not lexorank. Lexorank uses strings and buckets and a completely different set of math to work it out.
Here is answer for WeKan https://news.ycombinator.com/item?id=44165257
For realtime updates, Meteor web framework reads realtime changes from MongoDB OpLog (operations log), and with Publish/Subscribe at realtime updates all changes immediately for all users, like what card moved, etc.
There is in progress of adding support for other databases, like SQLite etc.
Thank your for this info!