Skip to main content
0 online
iwz iwz

I have comment threading working (display only).

The model for storing comments in the current ezabel schema is an Adjacency List. I have a parent_id that references the id of it's parent in the same table.

(side note: the current java code actually stores the comment_id in the parent_id column. So if you reply to the first post in a thread (#1), which is comment.id = 327911, a 1 will be put into the parent_id, instead of 327911. yay for no referential integrity! :( so i ran a migration that fixes all the data. since MySQL doesn't allow you to issue an update that has a subquery referencing the same table, i had to process it a row at a time. took like 3 hours locally. uggg. can't wait to run it again on the prod db)

So, anyway, I'm using Rails' built-in acts_as_tree, which supports the Adjacency List model. It knows about parent_id and what it means. The bad part is that it uses multiple queries to retrieve all the nested comments. So to retrieve a thread with 400 comments takes like 25 seconds. UGGGG

The other built-in option in Rails is acts_as_nested_set. This is much more efficient for querying, but it will be a HUGE pain to migrate the data to the schema required for that.

I could implement my own sort of acts_as_tree loader that loads up all the comments for a thread in one query and then threads them in memory (similar to how the current Java code works). But I'm really not familiar enough with Ruby or Rails yet to even start to figure it out.

Anyway, I feel like I'm making some progress. Once the basic functionality of the commenting system is in place (alllmost there, just need to get replies working), it really should be a breeze to finish the rest up.

Anybody know of a place I can set up an SVN repository?

deanh77 deanh77Founder

not sure how easy it is to get an project up there, but you could try rubyforge.net

rubyforge is only open-source, but you can still control the commiters list, I believe.

Welcome Back to eZabel

It's been a while. Here's what's new.

eZabel Lore

A complete history of our community — stats, Hall of Fame, legendary threads, and more.

View the Lore →

Everything Preserved

All 225,969 pieces of content from 2000–2014 are here — forums, messages, journals, photos, polls, and events.

💎

Gems

Spot something you love — a legendary comment, a classic thread, a great photo? Log in and click the diamond icon to mark it as a Gem. Add a note about why it's special. The best stuff surfaces on the Gems page.