Hi forum!
Please have a look at this link first:
http://www.odamoz.org.mz/reports/rpt_own.asp
I’m currently trying to refactor that in Rails, here’s some more info
first:
- We are looking for Projects.
- A project has_and_belongs_to_many MDGs, Donors, Provinces and Sectors.
My initial idea would lead to a horrible performance, so any other ideas
are appreciated.
Here is it, though:
- Get all projects for each of the selected items
- Join and unify the result arrays using the & operator.
[code=]mdg_prj = MDG.find(params[:mdgs]).projects
donor_prj = Donor.find(params[:donors]).projects
province_prj = Province.find(params[:provinces]).projects
sector_prj = DacSector.find(params[:sectors]).projects
prj_result = mdg_prj & donor_prj & province_prj & sector_prj[/code]
Image this with >10000 projects…
Does anyone of you have any idea? That’s really driving me nuts.
Regards,
Pascal