From 8f46653345c429e61cffcc25e5afefc74887d5ab Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 17 May 2013 09:03:30 +1000 Subject: [PATCH] refactor --- app/models/group.rb | 10 ++++------ lib/freedom_patches/performance_fixes.rb | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/models/group.rb b/app/models/group.rb index c96248ebd29..011cc297ba9 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -49,7 +49,8 @@ class Group < ActiveRecord::Base extra_users = group.users.where("users.id NOT IN (#{real_ids})").select('users.id') - missing_users = GroupUser.joins("RIGHT JOIN (#{real_ids}) X ON X.id = user_id AND group_id = #{group.id}") + missing_users = GroupUser + .joins("RIGHT JOIN (#{real_ids}) X ON X.id = user_id AND group_id = #{group.id}") .where("user_id IS NULL") .select("X.id") @@ -77,15 +78,12 @@ class Group < ActiveRecord::Base end def self.[](name) - unless g = lookup_group(name) - g = refresh_automatic_group!(name) - end - g + lookup_group(name) || refresh_automatic_group!(name) end def self.lookup_group(name) raise ArgumentError, "unknown group" unless id = AUTO_GROUPS[name] - g = Group.where(id: id).first + Group.where(id: id).first end diff --git a/lib/freedom_patches/performance_fixes.rb b/lib/freedom_patches/performance_fixes.rb index 74d0e2e06c5..30827702a67 100644 --- a/lib/freedom_patches/performance_fixes.rb +++ b/lib/freedom_patches/performance_fixes.rb @@ -14,6 +14,7 @@ class ActionView::Helpers::AssetTagHelper::AssetIncludeTag private # pluralization is fairly expensive, and pluralizing the word javascript 400 times is pointless + # this is fixed in Rails 4 def path_to_asset(source, options = {}) asset_paths.compute_public_path(source, pluralize_asset_name(asset_name), options.merge(:ext => extension))