Class: UpdatePostsPerHourJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/update_posts_per_hour_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(*_args) ⇒ Object


4
5
6
7
8
9
# File 'app/jobs/update_posts_per_hour_job.rb', line 4

def perform(*_args)
  Blog.find_each do |blog|
    posts_per_hour = blog.posts.newer_than(1.week.ago).count.to_f / (7 * 24).to_f
    blog.update_column :posts_per_hour, posts_per_hour
  end
end