From 190daa76ddb3e98234cade856492c71fe1235bce Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Fri, 21 Jan 2011 11:11:58 -0800 Subject: [PATCH] getting rid of gruff and it's imagemagic deps. made graphs on stats pending. --- Gemfile | 4 ---- Gemfile.lock | 4 ---- app/controllers/statistics_controller.rb | 7 ++----- app/models/statistic.rb | 14 +------------- app/views/statistics/show.html.haml | 11 ++++++++++- spec/controllers/statistics_controller_spec.rb | 1 + spec/models/statistic_spec.rb | 1 + 7 files changed, 15 insertions(+), 27 deletions(-) diff --git a/Gemfile b/Gemfile index af63a4182..4c739a098 100644 --- a/Gemfile +++ b/Gemfile @@ -43,10 +43,6 @@ gem 'rest-client', '1.6.1' #Backups gem 'cloudfiles', '1.4.10', :require => false -#Statistics -gem 'gruff' -gem 'rmagick' - #Queue gem 'resque', '1.10.0' gem 'SystemTimer', '1.2.1' unless RUBY_VERSION.include? '1.9' diff --git a/Gemfile.lock b/Gemfile.lock index a6899cee5..95cdd3671 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -176,7 +176,6 @@ GEM gem_plugin (0.2.3) gherkin (2.3.3) json (~> 1.4.6) - gruff (0.3.6) haml (3.0.25) hashie (0.4.0) highline (1.6.1) @@ -293,7 +292,6 @@ GEM vegas (~> 0.1.2) rest-client (1.6.1) mime-types (>= 1.16) - rmagick (2.13.1) rspec (2.4.0) rspec-core (~> 2.4.0) rspec-expectations (~> 2.4.0) @@ -376,7 +374,6 @@ DEPENDENCIES fastercsv (= 1.5.4) fixture_builder (~> 0.2.0) fog - gruff haml (= 3.0.25) http_accept_language! jammit (= 0.5.4) @@ -392,7 +389,6 @@ DEPENDENCIES rails (= 3.0.3) resque (= 1.10.0) rest-client (= 1.6.1) - rmagick roxml! rspec (>= 2.0.0) rspec-instafail diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index f15b698d8..cac670ed0 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -8,6 +8,7 @@ class StatisticsController < ApplicationController def show @statistic = Statistic.where(:id => params[:id]).first + @distribution = @statistic.distribution_as_array end def generate_single @@ -16,11 +17,7 @@ class StatisticsController < ApplicationController end def graph - @statistic = Statistic.where(:id => params[:id]).first - send_data(@statistic.generate_graph, - :disposition => 'inline', - :type => 'image/png', - :filename => "stats.png") + # need to use google's graph API end private diff --git a/app/models/statistic.rb b/app/models/statistic.rb index c5da05dc5..6ec3f4aff 100644 --- a/app/models/statistic.rb +++ b/app/models/statistic.rb @@ -40,19 +40,7 @@ class Statistic < ActiveRecord::Base end def generate_graph - g = Gruff::Bar.new - 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 + # need to use google's graph API end def self.generate(time=Time.now, post_range=(0..50)) diff --git a/app/views/statistics/show.html.haml b/app/views/statistics/show.html.haml index a2f0048da..1f71e7e65 100644 --- a/app/views/statistics/show.html.haml +++ b/app/views/statistics/show.html.haml @@ -6,7 +6,16 @@ %h3 = "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 = link_to 'all statistics', statistics_path diff --git a/spec/controllers/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb index 2b6697442..5b0429ad3 100644 --- a/spec/controllers/statistics_controller_spec.rb +++ b/spec/controllers/statistics_controller_spec.rb @@ -35,6 +35,7 @@ describe StatisticsController do describe '#graph' do it 'generates a graph' do + pending "need to use google graph API" get :graph, :id => @stat.id response.should be_success end diff --git a/spec/models/statistic_spec.rb b/spec/models/statistic_spec.rb index 2187764f4..f01c9d23a 100644 --- a/spec/models/statistic_spec.rb +++ b/spec/models/statistic_spec.rb @@ -75,6 +75,7 @@ describe Statistic do describe '#generate_graph' do it 'outputs a binary string' do + pending "should use google graph API" @stat.generate_graph.class.should == String end end