[PATCH 1/2] BZ 848090 clarify statistics method as user_statistics; remove unneeded statistics

Tzu-Mainn Chen tzumainn at redhat.com
Wed Aug 22 16:55:15 UTC 2012


---
 src/app/controllers/pools_controller.rb            |   15 ++++-----------
 src/app/views/pools/_alerts_index.html.haml        |    8 ++++----
 .../views/pools/_scoreboard_index.html.mustache    |    2 +-
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/src/app/controllers/pools_controller.rb b/src/app/controllers/pools_controller.rb
index 00bec7f..8c472ee 100644
--- a/src/app/controllers/pools_controller.rb
+++ b/src/app/controllers/pools_controller.rb
@@ -83,7 +83,7 @@ class PoolsController < ApplicationController
         params[:page], PER_PAGE)
     end
 
-    statistics
+    user_statistics
     respond_to do |format|
       format.html { @view = filter_view? ? 'layouts/tabpanel' : 'pretty_list' }
       format.js do
@@ -402,19 +402,12 @@ class PoolsController < ApplicationController
     @pool.quota.set_maximum_running_instances(limit)
   end
 
-  def statistics
-    instances = current_user.owned_instances
-    failed_instances = instances.failed
-    @statistics = {
-              :pools_in_use => @user_pools.select { |pool| pool.instances.pending_or_deployed.count > 0 }.count,
-              :deployments => current_user.deployments.count,
-              :instances => instances.count,
-              :instances_pending => instances.select {|instance| instance.state == Instance::STATE_NEW || instance.state == Instance::STATE_PENDING}.count,
+  def user_statistics
+    failed_instances = current_user.owned_instances.failed
+    @user_statistics = {
               :instances_failed => failed_instances,
               :instances_failed_count => failed_instances.count,
               :user_available_quota => current_user.quota.maximum_running_instances,
-              :user_running_instances => current_user.quota.running_instances,
-              :user_used_percentage => current_user.quota.percentage_used
               }
   end
 end
diff --git a/src/app/views/pools/_alerts_index.html.haml b/src/app/views/pools/_alerts_index.html.haml
index 29cbbd9..ed0e564 100644
--- a/src/app/views/pools/_alerts_index.html.haml
+++ b/src/app/views/pools/_alerts_index.html.haml
@@ -1,15 +1,15 @@
-- if @statistics[:instances_failed_count] > 0
+- if @user_statistics[:instances_failed_count] > 0
   %section.content-section.alerts.collapse_entity
     %header
       .section-controls
-        = link_to t("providers.edit.toggle_alerts"), "#", :class => 'collapse alerts' unless @statistics[:instances_failed].blank?
+        = link_to t("providers.edit.toggle_alerts"), "#", :class => 'collapse alerts' unless @user_statistics[:instances_failed].blank?
       %h2.alerts
         =t "alerts_label"
-        %span.label.badge.alert.count= @statistics[:instances_failed_count]
+        %span.label.badge.alert.count= @user_statistics[:instances_failed_count]
     .content.collapsible
       %dl.alerts
         %ul
-          - @statistics[:instances_failed].each do |inst|
+          - @user_statistics[:instances_failed].each do |inst|
             %li.alert
               %dt.subject.critical= inst.name
               %dd.type=t "alerts.instance_failure"
diff --git a/src/app/views/pools/_scoreboard_index.html.mustache b/src/app/views/pools/_scoreboard_index.html.mustache
index f0f46e0..3135b93 100644
--- a/src/app/views/pools/_scoreboard_index.html.mustache
+++ b/src/app/views/pools/_scoreboard_index.html.mustache
@@ -32,7 +32,7 @@
       <dd class="fraction instance">
         <span class="part">{{user_running_instances}}</span>
         <span class="divider label small caps">of</span>
-        <span class="total"><%= @statistics[:user_available_quota].nil? ? raw('&infin;') : @statistics[:user_available_quota] %></span>
+        <span class="total"><%= @user_statistics[:user_available_quota].nil? ? raw('&infin;') : @user_statistics[:user_available_quota] %></span>
       </dd>
     </li>
   </ul>
-- 
1.7.6.5




More information about the aeolus-devel mailing list