Permalink
Browse files

Neaten up the user count algorithms

  • Loading branch information...
1 parent b217c01 commit 1d9ef5d582494ea406e8a2ebb30190d566e99136 @courtenay courtenay committed Aug 4, 2009
Showing with 7 additions and 4 deletions.
  1. +7 −4 app/helpers/users_helper.rb
@@ -1,14 +1,17 @@
module UsersHelper
+ # todo: make this use "size" instead of "count" and maybe cache it
def user_count
- pluralize current_site.users.size, 'user'[:user]
+ pluralize current_site.users.count, 'user'[:user]
end
-
+
+ # todo: cache this?
def active_user_count
- pluralize current_site.users.find(:all, :conditions => "posts_count > 0").size, 'active user'[:active_user]
+ pluralize current_site.users.count(:conditions => "users.posts_count > 0"), 'active user'[:active_user]
end
+ # todo: cache this?
def lurking_user_count
- pluralize current_site.users.find(:all, :conditions => "posts_count = 0").size, 'lurking user'[:lurking_user]
+ pluralize current_site.users.count(:conditions => "users.posts_count < 1"), 'lurking user'[:lurking_user]
end
#

0 comments on commit 1d9ef5d

Please sign in to comment.