Questions for displaying aggregated results (batch processing) on the screen

Asked 2 years ago, Updated 2 years ago, 41 views

Currently, we have created a ranking model similar to the following, and we are saving the ranking of each user's games.(Rails 4 Series)

Based on this ranking, we write a program that uses crontab to aggregate once a week.

---ranks ---
user_id:integer point:integer
--------------

I know where to count, but
I asked you a question because I didn't know the general method of displaying the total results on the screen.


because of the so-called batch processing?, it is not aggregated per access. I am thinking of creating a model to save the total results and putting the data in it.

I'm still inexperienced, so I don't know if this method is acceptable, and I would appreciate it if you could let me know if there is anything I should be careful about when using this method.

By the way, when we use crontab to aggregate, we write sql without crontab and execute it based on that. I would also like to know if that is the common method... There is no one around me who knows much about it, so I started it without making a decision

ruby-on-rails ruby

2022-09-30 14:03

1 Answers

I don't know if it's common or not.

I will make a ranking model and table and save the total results.
The display just shows it as it is.

The aggregation itself is done by creating a rake task.This will be done in crontab.

rake task examples:

namespace:ranking do
  desc "Total Ranking"
  task count_up: —environment do
    # actual processing
  end
end

There is a gem called whenever to operate the crontab, and I recommend it because it makes it easy to set the crontab.


2022-09-30 14:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.