I have a small SaaS app built in Rails, and my customers are asking for what I think would be described as business intelligence features. They want to see statistics about their data and usage.<p>I'm able to get the answers they are looking for using SQL, but as far as making it performant and user-ready, I'm not sure the best way to go about it. Can anyone point me to a good resource on implementing this correctly? I need to be able to do things like sort a list by most popular within a time range, run calculations for each row in a list and provide the output to a table, etc.