From 5a8e13c498a79004dde5a5d23c768ec052bc2d4a Mon Sep 17 00:00:00 2001 From: "ccooper%deadsquid.com" Date: Tue, 22 Aug 2006 23:02:43 +0000 Subject: [PATCH] b=349746 - add trusted coverage display --- webtools/litmus/Litmus/DB/Subgroup.pm | 93 ++++++++++++++----- webtools/litmus/Litmus/DB/Testcase.pm | 44 +++++---- webtools/litmus/Litmus/DB/Testgroup.pm | 2 + webtools/litmus/Litmus/DB/Testresult.pm | 14 +++ webtools/litmus/css/litmus.css | 3 + .../runtests/selectgroupsubgroup.html.tmpl | 56 ++++++++--- .../en/default/runtests/testdisplay.html.tmpl | 11 ++- 7 files changed, 167 insertions(+), 56 deletions(-) diff --git a/webtools/litmus/Litmus/DB/Subgroup.pm b/webtools/litmus/Litmus/DB/Subgroup.pm index 734a0b4c6cc5..88d6d3c3403e 100755 --- a/webtools/litmus/Litmus/DB/Subgroup.pm +++ b/webtools/litmus/Litmus/DB/Subgroup.pm @@ -48,42 +48,60 @@ Litmus::DB::Subgroup->column_alias("subgroup_id", "subgroupid"); Litmus::DB::Subgroup->has_a(product => "Litmus::DB::Product"); __PACKAGE__->set_sql(EnabledByTestgroup => qq{ - SELECT sg.* - FROM subgroups sg, subgroup_testgroups sgtg - WHERE sgtg.testgroup_id=? AND sgtg.subgroup_id=sg.subgroup_id AND sg.enabled=1 - ORDER BY sgtg.sort_order ASC +SELECT sg.* +FROM subgroups sg, subgroup_testgroups sgtg +WHERE + sgtg.testgroup_id=? AND + sgtg.subgroup_id=sg.subgroup_id AND + sg.enabled=1 +ORDER BY sgtg.sort_order ASC }); __PACKAGE__->set_sql(ByTestgroup => qq{ - SELECT sg.* - FROM subgroups sg, subgroup_testgroups sgtg - WHERE sgtg.testgroup_id=? AND sgtg.subgroup_id=sg.subgroup_id - ORDER BY sgtg.sort_order ASC +SELECT sg.* +FROM subgroups sg, subgroup_testgroups sgtg +WHERE + sgtg.testgroup_id=? AND + sgtg.subgroup_id=sg.subgroup_id +ORDER BY sgtg.sort_order ASC }); __PACKAGE__->set_sql(NumCommunityEnabledTestcases => qq{ - SELECT count(tc.testcase_id) as num_testcases - FROM testcases tc, testcase_subgroups tcsg - WHERE tcsg.subgroup_id=? AND tcsg.testcase_id=tc.testcase_id AND tc.enabled=1 AND tc.community_enabled=1 +SELECT count(tc.testcase_id) AS num_testcases +FROM testcases tc, testcase_subgroups tcsg +WHERE + tcsg.subgroup_id=? AND + tcsg.testcase_id=tc.testcase_id AND + tc.enabled=1 AND + tc.community_enabled=1 }); + __PACKAGE__->set_sql(NumEnabledTestcases => qq{ - SELECT count(tc.testcase_id) as num_testcases - FROM testcases tc, testcase_subgroups tcsg - WHERE tcsg.subgroup_id=? AND tcsg.testcase_id=tc.testcase_id AND tc.enabled=1 +SELECT count(tc.testcase_id) AS num_testcases +FROM testcases tc, testcase_subgroups tcsg +WHERE + tcsg.subgroup_id=? AND + tcsg.testcase_id=tc.testcase_id AND + tc.enabled=1 }); __PACKAGE__->set_sql(EnabledByTestcase => qq{ - SELECT sg.* - FROM subgroups sg, testcase_subgroups tcsg - WHERE tcsg.testcase_id=? AND tcsg.subgroup_id=sg.subgroup_id AND sg.enabled=1 - ORDER by sg.name ASC +SELECT sg.* +FROM subgroups sg, testcase_subgroups tcsg +WHERE + tcsg.testcase_id=? AND + tcsg.subgroup_id=sg.subgroup_id AND + sg.enabled=1 +ORDER by sg.name ASC }); __PACKAGE__->set_sql(ByTestcase => qq{ - SELECT sg.* - FROM subgroups sg, testcase_subgroups tcsg - WHERE tcsg.testcase_id=? AND tcsg.subgroup_id=sg.subgroup_id - ORDER by sg.name ASC +SELECT sg.* +FROM subgroups sg, testcase_subgroups tcsg +WHERE + tcsg.testcase_id=? AND + tcsg.subgroup_id=sg.subgroup_id +ORDER by sg.name ASC }); ######################################################################### @@ -94,6 +112,7 @@ sub coverage() { my $locale = shift; my $community_only = shift; my $user = shift; + my $trusted = shift; my $sql = "SELECT COUNT(t.testcase_id) FROM testcase_subgroups tsg, testcases t WHERE tsg.subgroup_id=? AND tsg.testcase_id=t.testcase_id AND t.enabled=1"; if ($community_only) { @@ -111,16 +130,22 @@ sub coverage() { if (!$num_testcases or $num_testcases == 0) { return "N/A" } - + $sql = "SELECT t.testcase_id, count(tr.testresult_id) AS num_results - FROM testcase_subgroups tsg JOIN testcases t ON (tsg.testcase_id=t.testcase_id) LEFT JOIN test_results tr ON (tr.testcase_id=t.testcase_id) JOIN opsyses o ON (tr.opsys_id=o.opsys_id) - WHERE tsg.subgroup_id=? AND tr.build_id=? AND tr.locale_abbrev=? AND o.platform_id=?"; + FROM testcase_subgroups tsg JOIN testcases t ON (tsg.testcase_id=t.testcase_id) LEFT JOIN test_results tr ON (tr.testcase_id=t.testcase_id) JOIN opsyses o ON (tr.opsys_id=o.opsys_id)"; + if ($trusted) { + $sql .= ", users u"; + } + $sql .= " WHERE tsg.subgroup_id=? AND tr.build_id=? AND tr.locale_abbrev=? AND o.platform_id=?"; if ($community_only) { $sql .= " AND t.community_enabled=1"; } if ($user) { $sql .= " AND tr.user_id=" . $user->{'user_id'}; } + if ($trusted) { + $sql .= " AND tr.user_id=u.user_id AND u.is_admin=1"; + } $sql .= " GROUP BY tr.testcase_id"; @@ -152,6 +177,24 @@ sub coverage() { return sprintf("%d",$result); } +######################################################################### +sub getNumEnabledTestcases { + my $self = shift; + + my ($count) = $self->search_NumEnabledTestcases($self->subgroup_id); + + return $count->{'num_testcases'}; +} + +######################################################################### +sub getNumCommunityEnabledTestcases { + my $self = shift; + + my ($count) = $self->search_NumCommunityEnabledTestcases($self->subgroup_id); + + return $count->{'num_testcases'}; +} + ######################################################################### sub clone() { my $self = shift; diff --git a/webtools/litmus/Litmus/DB/Testcase.pm b/webtools/litmus/Litmus/DB/Testcase.pm index f0c61fe099f9..8c33e2a7f93c 100755 --- a/webtools/litmus/Litmus/DB/Testcase.pm +++ b/webtools/litmus/Litmus/DB/Testcase.pm @@ -61,12 +61,7 @@ Litmus::DB::Testcase->has_a("format" => "Litmus::DB::Format"); Litmus::DB::Testcase->has_a("author" => "Litmus::DB::User"); Litmus::DB::Testcase->has_a("product" => "Litmus::DB::Product"); -__PACKAGE__->set_sql(EnabledBySubgroup => qq{ - SELECT t.* - FROM testcases t, testcase_subgroups tsg - WHERE tsg.subgroup_id=? AND tsg.testcase_id=t.testcase_id AND t.enabled=1 - ORDER BY tsg.sort_order ASC -}); +Litmus::DB::Testcase->has_many(test_results => "Litmus::DB::Testresult", {order_by => 'submission_time DESC'}); __PACKAGE__->set_sql(BySubgroup => qq{ SELECT t.* @@ -87,17 +82,26 @@ WHERE ORDER BY tsg.sort_order ASC }); -__PACKAGE__->set_sql(CommunityEnabledBySubgroup => qq{ - SELECT t.* - FROM testcases t, testcase_subgroups tsg - WHERE tsg.subgroup_id=? AND tsg.testcase_id=t.testcase_id AND t.enabled=1 AND t.community_enabled=1 - ORDER BY tsg.sort_order ASC, t.testcase_id ASC +__PACKAGE__->set_sql(EnabledBySubgroup => qq{ +SELECT t.* +FROM testcases t, testcase_subgroups tsg +WHERE + tsg.subgroup_id=? AND + tsg.testcase_id=t.testcase_id AND + t.enabled=1 + ORDER BY tsg.sort_order ASC }); -Litmus::DB::Testcase->has_many(test_results => "Litmus::DB::Testresult", {order_by => 'submission_time DESC'}); - -Litmus::DB::Testcase->has_many(subgroups => - ["Litmus::DB::TestcaseSubgroup" => 'subgroup']); +__PACKAGE__->set_sql(CommunityEnabledBySubgroup => qq{ +SELECT t.* +FROM testcases t, testcase_subgroups tsg +WHERE + tsg.subgroup_id=? AND + tsg.testcase_id=t.testcase_id AND + t.enabled=1 AND + t.community_enabled=1 +ORDER BY tsg.sort_order ASC, t.testcase_id ASC +}); ######################################################################### # is_completed($$$$$) @@ -112,9 +116,17 @@ sub is_completed { my $build_id = shift; my $locale = shift; my $user = shift; # optional + my $trusted = shift; # optional my @results; - if ($user) { + if ($trusted) { + @results = Litmus::DB::Testresult->search_CompletedByTrusted( + $self->{'testcase_id'}, + $build_id, + $locale->{'abbrev'}, + $platform->{'platform_id'}, + ); + } elsif ($user) { @results = Litmus::DB::Testresult->search_CompletedByUser( $self->{'testcase_id'}, $build_id, diff --git a/webtools/litmus/Litmus/DB/Testgroup.pm b/webtools/litmus/Litmus/DB/Testgroup.pm index cb9027cd8bbb..969dd6bb6a5e 100755 --- a/webtools/litmus/Litmus/DB/Testgroup.pm +++ b/webtools/litmus/Litmus/DB/Testgroup.pm @@ -88,6 +88,7 @@ sub coverage { my $locale = shift; my $community_only = shift; my $user = shift; + my $trusted = shift; my $percent_completed = 0; @@ -100,6 +101,7 @@ sub coverage { $locale, $community_only, $user, + $trusted, ); if ($subgroup_percent eq "N/A") { $num_empty_subgroups++; diff --git a/webtools/litmus/Litmus/DB/Testresult.pm b/webtools/litmus/Litmus/DB/Testresult.pm index 55a9fc225a3e..970bf799d2f4 100755 --- a/webtools/litmus/Litmus/DB/Testresult.pm +++ b/webtools/litmus/Litmus/DB/Testresult.pm @@ -48,6 +48,7 @@ Litmus::DB::Testresult->columns(All => qw/testresult_id testcase_id last_updated Litmus::DB::Testresult->column_alias("testcase_id", "testcase"); Litmus::DB::Testresult->column_alias("submission_time", "timestamp"); +Litmus::DB::Testresult->column_alias("submission_time", "created"); Litmus::DB::Testresult->column_alias("user_id", "user"); Litmus::DB::Testresult->column_alias("opsys_id", "opsys"); Litmus::DB::Testresult->column_alias("branch_id", "branch"); @@ -119,6 +120,19 @@ Litmus::DB::Testresult->set_sql(CompletedByUser => qq{ ORDER BY tr.submission_time DESC }); +Litmus::DB::Testresult->set_sql(CompletedByTrusted => qq{ + SELECT tr.* + FROM test_results tr, opsyses o, users u + WHERE tr.testcase_id=? AND + tr.build_id=? AND + tr.locale_abbrev=? AND + tr.opsys_id=o.opsys_id AND + o.platform_id=? AND + tr.user_id=u.user_id AND + u.is_admin=1 + ORDER BY tr.submission_time DESC +}); + ######################################################################### # for historical reasons, note() is a shorthand way of saying "the text of # the first comment on this result if that comment was submitted by the diff --git a/webtools/litmus/css/litmus.css b/webtools/litmus/css/litmus.css index ab3129bf233e..ae84053e08d6 100755 --- a/webtools/litmus/css/litmus.css +++ b/webtools/litmus/css/litmus.css @@ -1060,6 +1060,9 @@ ol { .completegroup { background-color: #999999; } +.trustedcompletegroup { + background-color: #66CC66; +} .confirmedgroup { background-color: #666666; } diff --git a/webtools/litmus/templates/en/default/runtests/selectgroupsubgroup.html.tmpl b/webtools/litmus/templates/en/default/runtests/selectgroupsubgroup.html.tmpl index d006b689899a..e628c0efbcf3 100755 --- a/webtools/litmus/templates/en/default/runtests/selectgroupsubgroup.html.tmpl +++ b/webtools/litmus/templates/en/default/runtests/selectgroupsubgroup.html.tmpl @@ -71,6 +71,9 @@ Select Testing Group Name Personal Testing Coverage Community Testing Coverage +[% IF show_admin %] +Trusted Coverage +[% END %] [% IF defaultgroup.testgroup_id=="" %] @@ -82,7 +85,8 @@ Select Testing Group [% community_completed = curgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0) %] [% personal_completed = curgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0, user) %] - + [% trusted_completed = curgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0, 0, 1) %] + [% IF community_completed == 100 OR completed == 'N/A' %] [% groupstyle = 'completegroup' %] [% ELSE %] @@ -93,6 +97,12 @@ Select Testing Group [% END %] [% END %] + [% IF show_admin %] + [% IF trusted_completed == 100 %] + [% groupstyle = 'trustedcompletegroup' %] + [% END %] + [% END %] + [% IF personal_completed != 100 AND @@ -110,6 +120,9 @@ Select Testing Group [% curgroup.name FILTER html %] [% personal_completed FILTER html %][% IF personal_completed != 'N/A' %]%[% END %] [% community_completed FILTER html %][% IF community_completed != 'N/A' %]%[% END %] + [% IF show_admin %] + [% trusted_completed FILTER html %][% IF trusted_completed != 'N/A' %]%[% END %] + [% END %] [% END %] @@ -134,13 +147,19 @@ Select Subgroup

-[% headerrow = 'NameNumber of TestsPersonal Testing CoverageCommunity Testing Coverage' %] +[% IF show_admin %] + [% headerrow = 'NameNumber of TestsPersonal Testing CoverageCommunity Testing CoverageTrusted Coverage' %] + [% colspan = 5 %] +[% ELSE %] + [% headerrow = 'NameNumber of TestsPersonal Testing CoverageCommunity Testing Coverage' %] + [% colspan = 4 %] +[% END %]

[% headerrow | none %] - @@ -160,29 +179,40 @@ Please select a testing group with testcases, or that has not yet been tested in [% community_completed = cursubgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0) %] [% personal_completed = cursubgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0, user) %] + [% trusted_completed = cursubgroup.coverage(sysconfig.platform, sysconfig.build_id, sysconfig.locale, 0, 0, 1) %] [% IF community_completed == 100 OR completed == 'N/A' %] - [% groupstyle = 'completegroup' %] + [% groupstyle = 'completegroup' %] [% ELSE %] - [% IF not (loop.count % 2) %] - [% groupstyle = 'even' %] - [% ELSE %] - [% groupstyle = 'odd' %] - [% END %] + [% IF not (loop.count % 2) %] + [% groupstyle = 'even' %] + [% ELSE %] + [% groupstyle = 'odd' %] + [% END %] + [% END %] + + [% IF show_admin %] + [% IF trusted_completed == 100 %] + [% groupstyle = 'trustedcompletegroup' %] + [% END %] [% END %] [% IF show_admin %] - [% counttests = cursubgroup.search_NumCommunityEnabledTestcases(cursubgroup.subgroup_id) %] + [% counttests = cursubgroup.getNumEnabledTestcases() %] [% ELSE %] - [% counttests = cursubgroup.search_NumCommunityEnabledTestcases(cursubgroup.subgroup_id) %] + [% counttests = cursubgroup.getNumCommunityEnabledTestcases() %] [% END %] + - - + + [% IF show_admin %] + + [% END %] [% END %]
+ Please select a testing group with testcases, or that has not yet been tested in its entirety.
[% cursubgroup.name FILTER html %][% IF ! counttests.num_testcases %] 0 [% ELSE %] [% counttests.num_testcases %] [% END %][% IF ! counttests %] 0 [% ELSE %] [% counttests %] [% END %] [% personal_completed FILTER html %][% IF personal_completed != 'N/A' %]%[% END %] [% community_completed FILTER html %][% IF community_completed != 'N/A' %]%[% END %][% trusted_completed FILTER html %][% IF trusted_completed != 'N/A' %]%[% END %]
diff --git a/webtools/litmus/templates/en/default/runtests/testdisplay.html.tmpl b/webtools/litmus/templates/en/default/runtests/testdisplay.html.tmpl index d18499b635a7..99d9863be534 100755 --- a/webtools/litmus/templates/en/default/runtests/testdisplay.html.tmpl +++ b/webtools/litmus/templates/en/default/runtests/testdisplay.html.tmpl @@ -86,14 +86,21 @@ -[% results=curtest.is_completed(sysconfig.platform,sysconfig.build_id,sysconfig.locale,defaultemail) %] +[% IF show_admin %] + [% results=curtest.is_completed(sysconfig.platform,sysconfig.build_id,sysconfig.locale,defaultemail,show_admin) %] + [% already_run_text = 'A trusted tester has already submitted a result for this testcase.' %] +[% ELSE %] + [% results=curtest.is_completed(sysconfig.platform,sysconfig.build_id,sysconfig.locale,defaultemail) %] + [% already_run_text = 'You have already submitted a result for this testcase.' %] +[% END %] + [% IF results %][% testcase_class="testcase-completed" %][% ELSE %][% testcase_class="testcase" %][% END %]
-
[% loop.count %]: [% curtest.summary | html %] »[% IF results %] [% END %] + [% IF results %] [% END %] View[% IF show_admin %] / Edit[% END %]