getting rid of gruff and it's imagemagic deps. made graphs on stats pending.

This commit is contained in:
zhitomirskiyi 2011-01-21 11:11:58 -08:00
parent 403490364a
commit 190daa76dd
7 changed files with 15 additions and 27 deletions

View file

@ -43,10 +43,6 @@ gem 'rest-client', '1.6.1'
#Backups #Backups
gem 'cloudfiles', '1.4.10', :require => false gem 'cloudfiles', '1.4.10', :require => false
#Statistics
gem 'gruff'
gem 'rmagick'
#Queue #Queue
gem 'resque', '1.10.0' gem 'resque', '1.10.0'
gem 'SystemTimer', '1.2.1' unless RUBY_VERSION.include? '1.9' gem 'SystemTimer', '1.2.1' unless RUBY_VERSION.include? '1.9'

View file

@ -176,7 +176,6 @@ GEM
gem_plugin (0.2.3) gem_plugin (0.2.3)
gherkin (2.3.3) gherkin (2.3.3)
json (~> 1.4.6) json (~> 1.4.6)
gruff (0.3.6)
haml (3.0.25) haml (3.0.25)
hashie (0.4.0) hashie (0.4.0)
highline (1.6.1) highline (1.6.1)
@ -293,7 +292,6 @@ GEM
vegas (~> 0.1.2) vegas (~> 0.1.2)
rest-client (1.6.1) rest-client (1.6.1)
mime-types (>= 1.16) mime-types (>= 1.16)
rmagick (2.13.1)
rspec (2.4.0) rspec (2.4.0)
rspec-core (~> 2.4.0) rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0) rspec-expectations (~> 2.4.0)
@ -376,7 +374,6 @@ DEPENDENCIES
fastercsv (= 1.5.4) fastercsv (= 1.5.4)
fixture_builder (~> 0.2.0) fixture_builder (~> 0.2.0)
fog fog
gruff
haml (= 3.0.25) haml (= 3.0.25)
http_accept_language! http_accept_language!
jammit (= 0.5.4) jammit (= 0.5.4)
@ -392,7 +389,6 @@ DEPENDENCIES
rails (= 3.0.3) rails (= 3.0.3)
resque (= 1.10.0) resque (= 1.10.0)
rest-client (= 1.6.1) rest-client (= 1.6.1)
rmagick
roxml! roxml!
rspec (>= 2.0.0) rspec (>= 2.0.0)
rspec-instafail rspec-instafail

View file

@ -8,6 +8,7 @@ class StatisticsController < ApplicationController
def show def show
@statistic = Statistic.where(:id => params[:id]).first @statistic = Statistic.where(:id => params[:id]).first
@distribution = @statistic.distribution_as_array
end end
def generate_single def generate_single
@ -16,11 +17,7 @@ class StatisticsController < ApplicationController
end end
def graph def graph
@statistic = Statistic.where(:id => params[:id]).first # need to use google's graph API
send_data(@statistic.generate_graph,
:disposition => 'inline',
:type => 'image/png',
:filename => "stats.png")
end end
private private

View file

@ -40,19 +40,7 @@ class Statistic < ActiveRecord::Base
end end
def generate_graph def generate_graph
g = Gruff::Bar.new # need to use google's graph API
g.title = "Posts per user today"
g.data("Users", self.distribution_as_array)
h = {}
distribution.keys.each do |k|
if k.to_i%10 ==0
h[k.to_i] = k.to_s
end
end
g.labels = h
g.to_blob
end end
def self.generate(time=Time.now, post_range=(0..50)) def self.generate(time=Time.now, post_range=(0..50))

View file

@ -6,7 +6,16 @@
%h3 %h3
= "Users in sample: #{@statistic.users_in_sample}" = "Users in sample: #{@statistic.users_in_sample}"
= image_tag( "/statistics/graph/#{@statistic.id}")
%h5
(graph implementation pending)
- for pos in (0..@distribution.length-1)
%b
= pos
= @distribution[pos]
%br
%br %br
= link_to 'all statistics', statistics_path = link_to 'all statistics', statistics_path

View file

@ -35,6 +35,7 @@ describe StatisticsController do
describe '#graph' do describe '#graph' do
it 'generates a graph' do it 'generates a graph' do
pending "need to use google graph API"
get :graph, :id => @stat.id get :graph, :id => @stat.id
response.should be_success response.should be_success
end end

View file

@ -75,6 +75,7 @@ describe Statistic do
describe '#generate_graph' do describe '#generate_graph' do
it 'outputs a binary string' do it 'outputs a binary string' do
pending "should use google graph API"
@stat.generate_graph.class.should == String @stat.generate_graph.class.should == String
end end
end end