Forulio - Ruby on Rails based forum engine

I haven’t defined any indexes on any of the tables, and I probably
should.

Lightning fast you say? This is interesting.

Man, that last_post caching was probably such a bad hack feels ashamed

On Wed, Mar 12, 2008 at 11:17 PM, Frederick C. <
[email protected]> wrote:

lookup of 1 post, rather than a million.


Ryan B.

Feel free to add me to MSN and/or GTalk as this email.

On Mar 12, 12:48 am, “Ryan B. (Radar)” [email protected]
wrote:

s.ross, that will find the latest topic, not necessarily the the latest
post. For example, I create two topics, Topic A and Topic B. It says that
Topic B is the newest topic. I post in Topic A, and using your code Topic B
will still display as the latest topic.

if your database supports subselects (like PostgreSQL), you could do a
find_by_sql with sql like this:

SELECT DISTINCT t.*, last_post
FROM topics t
JOIN (SELECT topic_id, MAX(created_at) FROM posts GROUP BY topic_id)
as foo
ON (foo.topic_id = t.id)
ORDER BY last_post DESC

This will involve a full table scan on posts and topics, but should
work well until you have a very large database. It will always be
faster than doing the equivalent processing in ruby/rails using
ActiveRecord objects.

However, when your forum became very large and successful, you’d have
to optimize this by storing last_post_id, updating when posts are
created, and set up

belongs_to :last_post, :class_name => ‘Post’, :foreign_key
=> :last_post_id

then in a single

Topic.find(:all, :include => [:last_post], :order => “post.created_at
DESC”)

you could load the Topics, in descending order by last post, with the
last post already instantiated so you could show those details in your
listing, and it would be easy to add the appropriate limit and offset
parameters for paging. That’s what I would do, if I was writing forum
software…

Jim Crate
Que Viva, LLC

On 12 Mar 2008, at 13:00, Ryan B. (Radar) wrote:

I haven’t defined any indexes on any of the tables, and I probably
should.

Lightning fast you say? This is interesting.

Yes - if you’ve got an index on a column then finding the first/last n
values in the table, ordered by that column is fast because the
database can use its index
In the second case (find the last post in topic x) then if you have an
index on [topic_id, created_at] then finding the first/last n values
order by created_at where topic_id is some fixed value is also fast
I mostly know about mysql but mysql isn’t usually smarter than
postgres etc… so I would had thought most dbs would be good at this.

Fred.

Hey!

How does this differ from Technoweenie’s Altered Beast?

Mvh,
Kyrre

----- Original Message -----
From: Oleksandr B. [email protected]
Date: Saturday, March 29, 2008 9:27 pm
Subject: [Rails] Re: Forulio - Ruby on Rails based forum engine
To: [email protected]

Happened!
First beta is out and available for checkout from
http://svn2.assembla.com/svn/forumbla/releases/0.1.0
You can also always has latest changes at
http://svn2.assembla.com/svn/forumbla/trunk

You are welcome to test and discuss at http://forulio.com/topics/21

Hey!

How does this differ from Technoweenie’s Altered Beast?

Kyrre

----- Original Message -----
From: Oleksandr B. [email protected]
Date: Saturday, March 29, 2008 9:27 pm
Subject: [Rails] Re: Forulio - Ruby on Rails based forum engine
To: [email protected]

How does this differ from Technoweenie’s Altered Beast?

It has cool ajax integration, light and powerful localization system
included. And what is very important Forulio is actively developing.