Class: Rutema::UI::StatisticsController

Inherits:
Ramaze::Controller
  • Object
show all
Includes:
Settings, ViewUtilities
Defined in:
lib/rutemaweb/ramaze_controller.rb

Constant Summary

Constants included from ViewUtilities

ViewUtilities::IMG_LEFT, ViewUtilities::IMG_RIGHT, ViewUtilities::IMG_SCE_ERROR, ViewUtilities::IMG_SCE_OK, ViewUtilities::IMG_SCE_WARN, ViewUtilities::IMG_STEP_ERROR, ViewUtilities::IMG_STEP_OK, ViewUtilities::IMG_STEP_WARN, ViewUtilities::TIME_FORMAT

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Settings

#show_setup_teardown=, #show_setup_teardown?

Methods included from ViewUtilities

#cfg_link, #context_table, #run_link, #run_page_link, #run_summary, #run_url, #scenario_page_link, #scenario_status, #status_icon, #time_formatted

Class Method Details

.gruff_working=(v) ⇒ Object



352
353
354
# File 'lib/rutemaweb/ramaze_controller.rb', line 352

def self.gruff_working= v
  @@gruff_working= v
end

.gruff_working?Boolean

Returns:

  • (Boolean)


355
356
357
# File 'lib/rutemaweb/ramaze_controller.rb', line 355

def self.gruff_working?
  return @@gruff_working
end

Instance Method Details

#config_report(configuration = nil) ⇒ Object



378
379
380
381
382
383
384
385
386
387
388
# File 'lib/rutemaweb/ramaze_controller.rb', line 378

def config_report configuration=nil
  @title=configuration || "All configurations" 
  @panel_content=panel_configurations
  @content_title= configuration || "All configurations"
  if StatisticsController.gruff_working?
    @content="<img src=\"/statistics/graph/#{configuration}\"/>"
  else
    @content="Could not generate graph.<p>This is probably due to a missing gruff/RMagick installation.</p><p>You will need to restart rutemaweb once the issue is resolved.</p>"
  end
  return @content
end

#graph(configuration = nil) ⇒ Object



389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/rutemaweb/ramaze_controller.rb', line 389

def graph configuration=nil
  response.header['Content-type'] = "image/png"
  successful=[]
  failed=[]
  labels=Hash.new
  runs=Rutema::Model::Run.find(:all)
  #find all runs beloging to this configuration
  runs=runs.select{|r| r.context[:config_file]==configuration if r.context.is_a?(Hash)} if configuration
  #now extract the data
  counter=0
  #the normalizer thins out the labels on the x axis so that they won't overlap
  normalizer = 1
  normalizer=runs.size/11 unless runs.size<=11
  runs.each do |r|
    fails=r.number_of_failed
    #the scenarios array includes setup and teardown scripts as well - we want only the actual testcases
    #so we use the added number_of_tests method that filters setup and test scripts
    successful<<r.number_of_tests-fails
    failed<<fails
    #every Nth label
    labels[counter]="R#{r.id}" if counter%normalizer==0
    counter+=1
  end
  respond runs_graph_jpg(successful,failed,labels)
end

#indexObject



370
371
372
373
374
375
376
377
# File 'lib/rutemaweb/ramaze_controller.rb', line 370

def index
  @title="Rutema"
  @panel_content=panel_configurations
  @content_title="Statistics"
  @content="<p>rutema statistics provide reports that present the results on a time axis<br/>At present you can see the ratio of successful vs. failed test cases over time grouped per configuration file.</p>"
  @content<<"statistics reports require the gruff gem which in turn depends on RMagick. gruff does not appear to be available!<br/>rutemaweb will not be able to produce statistics reports" unless StatisticsController.gruff_working?
  @content
end