class PoolController < ApplicationController layout "bacuview-layout" def key_sql { "name" => "name", "name-" => "name desc", "type" => "pooltype", "type-" => "pooltype desc", "retain" => "volretention", "retain-" => "volretention desc", "vols" => "numvols", "vols-" => "numvols desc" } end def index @page_title = "Pools" @pool = Pool.find(:all, :order => sort_key(:psort, key_sql)) volume_counts = @pool.map{ |pool| pool.numvols } @max_vols = volume_counts.max @total_vols = volume_counts.inject(0) {|sum, i| sum + i} end def show @pool = Pool.find(params[:pid]) @page_title = "Pool " + @pool.name params[:action] = params[:pid] = nil end def dist return unless BACUVIEW['have_gruff'] g = Gruff::Pie.new(500) g.theme_37signals g.title = "Media Distribution" @pool = Pool.find(:all, :select => "name, numvols", :order => sort_key(:psort, key_sql)) for pool in @pool do g.data pool.name, [ pool.numvols ] end send_data(g.to_blob, :disposition => 'inline', :type => 'image/png') end end