Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

user: add method is_heavy_self_promoter? #427

Merged
merged 3 commits into from
Oct 25, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
user: query using association scope
  • Loading branch information
talklittle committed Oct 23, 2017
commit 7838cf1f3969801868e3f4767efb4e1558de47cf
5 changes: 1 addition & 4 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,7 @@ def is_heavy_self_promoter?
if total_count < MIN_STORIES_CHECK_SELF_PROMOTION
false
else
authored = Story.where(
{ :user_id => self.id, :user_is_author => true }
).count

authored = self.stories.where(:user_is_author => true).count
authored.to_f / total_count >= HEAVY_SELF_PROMOTER_PROPORTION
end
end
Expand Down