Displaying 1 result from an estimated 1 matches for "in_cluster_of_user".
2006 Oct 02
2
when to use find_by_sql
...bunch of queries to compute some counters, like
find_by_sql(<<-SQL
SELECT p.*, c.nfavourites
FROM people p, (
SELECT fp.person_id, COUNT(fp.user_id) as nfavourites
FROM favourite_people fp, users u
WHERE fp.user_id = u.id
AND u.cluster = ''#{in_cluster_of_user.cluster}''
GROUP BY fp.person_id
) as c
WHERE p.user_id IS NOT NULL
AND p.id = c.person_id
ORDER BY c.nfavourites DESC
LIMIT #{limit}
SQL
)
They do not map directly to find parameters and some convoluted Ruby
+AR would be needed to emulate them, a...