Re: Hierarchical comments Hacker News style

2012-06-03 Thread Randall Leeds
On Wed, May 16, 2012 at 2:40 AM, Luca Matteis lmatt...@gmail.com wrote: I'm trying to implement a basic way of displaying comments in the way that Hacker News provides, using CouchDB. Not only ordered hierarchically, but also, each level of the tree should be ordered by a points variable. If

Hierarchical comments Hacker News style

2012-05-16 Thread Luca Matteis
I'm trying to implement a basic way of displaying comments in the way that Hacker News provides, using CouchDB. Not only ordered hierarchically, but also, each level of the tree should be ordered by a points variable. If you're familiar with sites such as Hacker News or Reddit you know that each

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Tim McNamara
It may be worth looking at the reddit source code (github.com/reddit/reddit) to get some tips. Then you could adapt this into Couch. On May 16, 2012 9:41 PM, Luca Matteis lmatt...@gmail.com wrote: I'm trying to implement a basic way of displaying comments in the way that Hacker News provides,

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Nick North
I may be misunderstanding the problem, but would it work if you represent each comment by a list of its score and its id? Say comments 1, 2, 3, 4 have scores 40, 30, 20, 10 respectively, then the documents would become: { _id: 1, path: [[40,1]] }, { _id: 2, path: [[40,1], [30,2]] }, {

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Luca Matteis
Hi Nick, This in fact was also something I came up with. I ditched it because, like you said, it requires to update all the descendants. Which means a lot of extra overhead. Not only the direct descendants, but all the descendants. So a top comment could easily be replied more than 20 times, and

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Nick North
It needs someone much better with CouchDb than I am to find a better way. It feels hard to me, as changing the score of a document near the top of the tree can potentially move its whole subtree around in the ordering. If you want your view to contain all the documents in tree order, then

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Dirkjan Ochtman
On Wed, May 16, 2012 at 2:53 PM, Luca Matteis lmatt...@gmail.com wrote: Isn't there a better way? Since the ordering of descendants depends on the scores of ancestors (if you're talking about getting the whole thread in order), and you don't want to update descendants when ancestors get modified

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Luca Matteis
Ok. Where would it be appropriate to build such a tree? Can I do it in a list function? I'm using Couch directly and not interacting with it using other languages, so I need Couch to do all the work. On Wed, May 16, 2012 at 3:14 PM, Dirkjan Ochtman dirk...@ochtman.nl wrote: On Wed, May 16, 2012

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Benoit Chesneau
On Wed, May 16, 2012 at 3:19 PM, Luca Matteis lmatt...@gmail.com wrote: Ok. Where would it be appropriate to build such a tree? Can I do it in a list function? I'm using Couch directly and not interacting with it using other languages, so I need Couch to do all the work. On Wed, May 16, 2012

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Dirkjan Ochtman
On Wed, May 16, 2012 at 3:19 PM, Luca Matteis lmatt...@gmail.com wrote: Ok. Where would it be appropriate to build such a tree? Can I do it in a list function? I'm using Couch directly and not interacting with it using other languages, so I need Couch to do all the work. Should be possible to

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Sean Copenhaver
Is it not possible to maintain the scores and ordering in a document by itself? Something like { _id: whatever post: post id comments: { top level comment id: { score: ##, children: comments of similar structure }, another top level comment id : etc } } A view

Re: Hierarchical comments Hacker News style

2012-05-16 Thread Luca Matteis
Sean, interesting. What would be the drawbacks of this other than the conflict issue? How would I order the comments by score - would my view need to do the logic? Also, what if there's *many* comments to a post. How much can a single document handle? Luca On Wed, May 16, 2012 at 5:32 PM, Sean