diff --git a/app/models/impasse/test_plan.rb b/app/models/impasse/test_plan.rb index cafa271..8869c3c 100755 --- a/app/models/impasse/test_plan.rb +++ b/app/models/impasse/test_plan.rb @@ -14,21 +14,21 @@ class TestPlan < ActiveRecord::Base acts_as_customizable - def self.get_statistics_for_plan(version, plan) - total = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}'))))"] - ok = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '1' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}'))))"] - nog = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '2' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}'))))"] - block = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '3' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}'))))"] + def self.get_statistics_for_plan(version, plan, project) + total = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project}))))"] + ok = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '1' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project}))))"] + nog = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '2' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project}))))"] + block = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '3' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN(SELECT id FROM impasse_test_plans WHERE name = '#{plan}' AND version_id = ((SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project}))))"] nok = nog+block undone = total-nok-ok [total,ok,nog,block,undone] end - def self.get_statistics(version) - total = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}')))"] - ok = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '1' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}')))"] - nog = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '2' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}')))"] - block = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '3' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}')))"] + def self.get_statistics(version, project) + total = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project})))"] + ok = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '1' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project})))"] + nog = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '2' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project})))"] + block = count_by_sql ["SELECT count(status) FROM impasse_executions WHERE status = '3' AND test_plan_case_id IN (SELECT id FROM impasse_test_plan_cases WHERE test_plan_id IN (SELECT id FROM impasse_test_plans WHERE version_id IN (SELECT id FROM versions WHERE name = '#{version}' AND project_id = #{project})))"] nok = nog+block undone = total-nok-ok [total,ok,nog,block,undone] diff --git a/app/views/impasse_test_case/index.html.erb b/app/views/impasse_test_case/index.html.erb index 451bd15..f739a4f 100644 --- a/app/views/impasse_test_case/index.html.erb +++ b/app/views/impasse_test_case/index.html.erb @@ -145,11 +145,11 @@ TotalOKFailedIn processNo run <% plans[version].each do |test_plan| %> - <% total, ok, fail, proc, undone = Impasse::TestPlan.get_statistics_for_plan(version.name,test_plan.name) %> + <% total, ok, fail, proc, undone = Impasse::TestPlan.get_statistics_for_plan(version.name,test_plan.name, version.project_id) %> <%= link_to test_plan.name, :controller=>:impasse_test_plans, :action=>:show, :project_id=>@project, :id=>test_plan%><%= total%><%= ok%><%= fail%><%= proc%><%= undone%> <% end %> - <% total, ok, fail, proc, undone = Impasse::TestPlan.get_statistics(version.name) %> + <% total, ok, fail, proc, undone = Impasse::TestPlan.get_statistics(version.name, version.project_id) %> Total<%= total%><%= ok%><%= fail%><%= proc%><%= undone%>