Rails storing aggregated information

I am making a Rails application that will contain a lot of “computed” or “aggregated” data, that is, information that is computed by performing expensive operations on user-stored data. I think I need to somehow store this data, so A. I do not constantly perform expensive operations with the database and B. Therefore, I can spit out “reports” with good graphs over time, etc. For these attributes.

I am wondering what is the best way to implement this? I will need to calculate and save values ​​(numeric) for a given model and how they change over time. I want this to be efficient and avoid duplication and data. Entries will be pretty much fixed after being created, so I don’t have to worry about things changing too much, although they need to be taken into account.

I just wondered what the most common approach to this is, and how should I implement it in a Rails application?

+5
source share
1 answer

I am working on a similar issue, and I also worked on applications that did it wrong.

Here is my recommendation:

  • Save the raw data in the model, call Feed
  • " " , , . FeedStats. "--" "--", ; Feed - ..
  • . , - , , , , ..
  • , Resque ( ), DelayedJob .

, . .

+1

All Articles