Commit db9ac8e7 by tady

conform to rubocop

parent 8771f238
...@@ -45,7 +45,7 @@ class PostsController < ApplicationController ...@@ -45,7 +45,7 @@ class PostsController < ApplicationController
gflash error: 'Gmail authentication expired.' gflash error: 'Gmail authentication expired.'
redirect_to root_path(id: @post.id) redirect_to root_path(id: @post.id)
rescue ArgumentError => err rescue ArgumentError => err
gflash error: "Mail format is invalid: #{err.to_s}" gflash error: "Mail format is invalid: #{err}"
redirect_to root_path(id: @post.id) redirect_to root_path(id: @post.id)
end end
......
...@@ -91,13 +91,13 @@ class Post < ActiveRecord::Base ...@@ -91,13 +91,13 @@ class Post < ActiveRecord::Base
# Class method # Class method
###################################################################### ######################################################################
def self.most_pv_in_this_week(limit) def self.most_pv_in_this_week(limit)
posts_with_footprints = where(arel_table[:created_at].gt 1.week.ago). posts_with_footprints = where(arel_table[:created_at].gt 1.week.ago)
select("posts.id, count(footprints.id) AS footprints_count"). .select('posts.id, count(footprints.id) AS footprints_count')
joins(:footprints). .joins(:footprints)
group("posts.id"). .group('posts.id')
order("footprints_count DESC"). .order('footprints_count DESC')
limit(limit) .limit(limit)
posts = self.find(posts_with_footprints.map(&:id)) posts = find(posts_with_footprints.map(&:id))
posts.to_a.zip posts_with_footprints.map(&:footprints_count) posts.to_a.zip posts_with_footprints.map(&:footprints_count)
end end
......
...@@ -58,7 +58,6 @@ class User < ActiveRecord::Base ...@@ -58,7 +58,6 @@ class User < ActiveRecord::Base
scope :now_viewing, -> { joins(:footprints).where('footprints.updated_at > ?', 10.minutes.ago) } scope :now_viewing, -> { joins(:footprints).where('footprints.updated_at > ?', 10.minutes.ago) }
###################################################################### ######################################################################
# Validations # Validations
###################################################################### ######################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment