rubocop: Style/SymbolProc, 374
There were 18 &:foo and 19 {|x| x.foo}, so I updated to the new idiom.
This commit is contained in:
parent
52c8c2258d
commit
bf1885d87c
|
@ -230,7 +230,7 @@ class CommentsController < ApplicationController
|
|||
"hidden_stories WHERE user_id = ? AND " <<
|
||||
"hidden_stories.story_id = comments.story_id)", @user.id)
|
||||
|
||||
@votes = Vote.comment_votes_by_user_for_comment_ids_hash(@user.id, @comments.map {|c| c.id })
|
||||
@votes = Vote.comment_votes_by_user_for_comment_ids_hash(@user.id, @comments.map(&:id))
|
||||
|
||||
@comments.each do |c|
|
||||
if @votes[c.id]
|
||||
|
|
|
@ -270,9 +270,9 @@ private
|
|||
|
||||
def filtered_tag_ids
|
||||
if @user
|
||||
@user.tag_filters.map {|tf| tf.tag_id }
|
||||
@user.tag_filters.map(&:tag_id)
|
||||
else
|
||||
tags_filtered_by_cookie.map {|t| t.id }
|
||||
tags_filtered_by_cookie.map(&:id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ class Comment < ActiveRecord::Base
|
|||
self.short_id,
|
||||
self.is_from_email ? "email" : nil,
|
||||
created_at.to_i,
|
||||
].reject {|p| !p }.join(".") << "@" << Rails.application.domain
|
||||
].reject(&:!).join(".") << "@" << Rails.application.domain
|
||||
end
|
||||
|
||||
def path
|
||||
|
|
|
@ -146,12 +146,8 @@ class Story < ActiveRecord::Base
|
|||
|
||||
def self.recalculate_all_hotnesses!
|
||||
# do the front page first, since find_each can't take an order
|
||||
Story.order("id DESC").limit(100).each do |s|
|
||||
s.recalculate_hotness!
|
||||
end
|
||||
Story.find_each do |s|
|
||||
s.recalculate_hotness!
|
||||
end
|
||||
Story.order("id DESC").limit(100).each(&:recalculate_hotness!)
|
||||
Story.find_each(&:recalculate_hotness!)
|
||||
true
|
||||
end
|
||||
|
||||
|
@ -182,7 +178,7 @@ class Story < ActiveRecord::Base
|
|||
{ :description => :markeddown_description },
|
||||
:comments_url,
|
||||
{ :submitter_user => :user },
|
||||
{ :tags => self.tags.map {|t| t.tag }.sort },
|
||||
{ :tags => self.tags.map(&:tag).sort },
|
||||
]
|
||||
|
||||
if options && options[:with_comments]
|
||||
|
@ -217,7 +213,7 @@ class Story < ActiveRecord::Base
|
|||
def calculated_hotness
|
||||
# take each tag's hotness modifier into effect, and give a slight bump to
|
||||
# stories submitted by the author
|
||||
base = self.tags.map {|t| t.hotness_mod }.sum + (self.user_is_author ? 0.25 : 0.0)
|
||||
base = self.tags.map(&:hotness_mod).sum + (self.user_is_author ? 0.25 : 0.0)
|
||||
|
||||
# give a story's comment votes some weight, ignoring submitter's comments
|
||||
cpoints = self.comments
|
||||
|
@ -235,7 +231,7 @@ class Story < ActiveRecord::Base
|
|||
.inject(&:+).to_f * 0.5
|
||||
|
||||
# mix in any stories this one cannibalized
|
||||
cpoints += self.merged_stories.map {|s| s.score }.inject(&:+).to_f
|
||||
cpoints += self.merged_stories.map(&:score).inject(&:+).to_f
|
||||
|
||||
# if a story has many comments but few votes, it's probably a bad story, so
|
||||
# cap the comment points at the number of upvotes
|
||||
|
@ -549,10 +545,9 @@ class Story < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def tagging_changes
|
||||
old_tags_a = self.taggings.reject {|tg| tg.new_record? }.map {|tg|
|
||||
old_tags_a = self.taggings.reject(&:new_record?).map {|tg|
|
||||
tg.tag.tag }.join(" ")
|
||||
new_tags_a = self.taggings.reject {|tg| tg.marked_for_destruction?
|
||||
}.map {|tg| tg.tag.tag }.join(" ")
|
||||
new_tags_a = self.taggings.reject(&:marked_for_destruction?).map {|tg| tg.tag.tag }.join(" ")
|
||||
|
||||
if old_tags_a == new_tags_a
|
||||
{}
|
||||
|
@ -563,8 +558,7 @@ class Story < ActiveRecord::Base
|
|||
|
||||
@_tags_a = []
|
||||
def tags_a
|
||||
@_tags_a ||= self.taggings.reject {|t| t.marked_for_destruction?
|
||||
}.map {|t| t.tag.tag }
|
||||
@_tags_a ||= self.taggings.reject(&:marked_for_destruction?).map {|t| t.tag.tag }
|
||||
end
|
||||
|
||||
def tags_a=(new_tag_names_a)
|
||||
|
|
|
@ -15,7 +15,7 @@ class Utils
|
|||
end
|
||||
|
||||
def self.silence_stream(*streams)
|
||||
on_hold = streams.collect {|stream| stream.dup }
|
||||
on_hold = streams.collect(&:dup)
|
||||
streams.each do |stream|
|
||||
stream.reopen("/dev/null")
|
||||
stream.sync = true
|
||||
|
|
|
@ -41,7 +41,7 @@ end
|
|||
def story_subject(story, prefix = "")
|
||||
ss = "#{prefix}#{story.title}"
|
||||
|
||||
story.tags.sort_by {|t| t.tag }.each do |t|
|
||||
story.tags.sort_by(&:tag).each do |t|
|
||||
ss << " [#{t.tag}]"
|
||||
end
|
||||
|
||||
|
@ -52,8 +52,7 @@ EMAIL_WIDTH = 72
|
|||
LAST_STORY_KEY = "mailing:last_story_id".freeze
|
||||
LAST_COMMENT_KEY = "mailing:last_comment_id".freeze
|
||||
|
||||
mailing_list_users = User.where("mailing_list_mode > 0").select {|u|
|
||||
u.is_active? }
|
||||
mailing_list_users = User.where("mailing_list_mode > 0").select(&:is_active?)
|
||||
|
||||
last_story_id = (Keystore.value_for(LAST_STORY_KEY) || Story.last.id).to_i
|
||||
|
||||
|
@ -67,7 +66,7 @@ Story.where("id > ? AND is_expired = ?", last_story_id, false).order(:id).each d
|
|||
s.save
|
||||
|
||||
mailing_list_users.each do |u|
|
||||
if (s.tags.map {|t| t.id } & u.tag_filters.map {|t| t.tag_id }).any?
|
||||
if (s.tags.map(&:id) & u.tag_filters.map(&:tag_id)).any?
|
||||
# story has tags this user has filtered out
|
||||
next
|
||||
end
|
||||
|
@ -150,7 +149,7 @@ Comment.where(
|
|||
next
|
||||
end
|
||||
|
||||
if (c.story.tags.map {|t| t.id } & u.tag_filters.map {|t| t.tag_id }).any?
|
||||
if (c.story.tags.map(&:id) & u.tag_filters.map(&:tag_id)).any?
|
||||
# story has tags this user has filtered out
|
||||
next
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue