diff --git a/webtools/litmus/Litmus/Auth.pm b/webtools/litmus/Litmus/Auth.pm index 6b298a8e100f..3a5982917156 100755 --- a/webtools/litmus/Litmus/Auth.pm +++ b/webtools/litmus/Litmus/Auth.pm @@ -57,7 +57,7 @@ my $cookie_expire_days = 7; my $curSession; # Given a username and password, validate the login. Returns the -# Lutmus::DB::User object associated with the username if the login +# Litmus::DB::User object associated with the username if the login # is sucuessful. Returns false otherwise. sub validate_login($$) { my $username = shift; @@ -488,7 +488,7 @@ sub setCookie { my $user_id = 0; if ($user) { - $user_id = $user->userid(); + $user_id = $user->user_id(); } if (!$expires or $expires eq '') { diff --git a/webtools/litmus/Litmus/DB/Testcase.pm b/webtools/litmus/Litmus/DB/Testcase.pm index c9449e0bcfdf..e59999f13a4c 100755 --- a/webtools/litmus/Litmus/DB/Testcase.pm +++ b/webtools/litmus/Litmus/DB/Testcase.pm @@ -42,6 +42,7 @@ use Litmus::Error; our $default_relevance_threshold = 1.0; our $default_match_limit = 25; +our $default_num_days = 7; Litmus::DB::Testcase->table('testcases'); @@ -69,8 +70,8 @@ __PACKAGE__->set_sql(EnabledBySubgroup => qq{ __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 + 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 }); @@ -97,7 +98,7 @@ sub is_completed { $build_id, $locale->{'abbrev'}, $platform->{'platform_id'}, - $user->{'user_id'}, + $user->{'user_id'}, ); } else { @results = Litmus::DB::Testresult->search_Completed( @@ -107,8 +108,8 @@ sub is_completed { $platform->{'platform_id'}, ); } - - return @results; + + return @results; } ######################################################################### @@ -117,28 +118,80 @@ sub getFullTextMatches() { my $text_snippet = shift; my $match_limit = shift; my $relevance_threshold = shift; - + if (!$match_limit) { $match_limit = $default_match_limit; } if (!$relevance_threshold) { $relevance_threshold = $default_relevance_threshold } - + __PACKAGE__->set_sql(FullTextMatches => qq{ - SELECT testcase_id, summary, MATCH (summary,steps,expected_results) AGAINST (?) AS relevance - FROM testcases - WHERE MATCH (summary,steps,expected_results) AGAINST (?) HAVING relevance > ? - ORDER BY relevance DESC, summary ASC - LIMIT $match_limit + SELECT testcase_id, summary, creation_date, last_updated, MATCH (summary,steps,expected_results) AGAINST (?) AS relevance + FROM testcases + WHERE MATCH (summary,steps,expected_results) AGAINST (?) HAVING relevance > ? + ORDER BY relevance DESC, summary ASC + LIMIT $match_limit }); - - + + return $self->search_FullTextMatches( $text_snippet, $text_snippet, $relevance_threshold - ); + ); +} + +######################################################################### +sub getNewTestcases() { + my $self = shift; + my $num_days = shift; + my $match_limit = shift; + + if (!$num_days) { + $num_days = $default_num_days; + } + + if (!$match_limit) { + $match_limit = $default_match_limit; + } + + __PACKAGE__->set_sql(NewTestcases => qq{ + SELECT testcase_id, summary, creation_date, last_updated + FROM testcases + WHERE creation_date>=? + LIMIT $match_limit +}); + + my $err; + my $new_datestamp=&UnixDate(DateCalc("now","- $num_days days"),"%q"); + return $self->search_NewTestcases($new_datestamp); +} + +######################################################################### +sub getRecentlyUpdated() { + my $self = shift; + my $num_days = shift; + my $match_limit = shift; + + if (!$num_days) { + $num_days = $default_num_days; + } + + if (!$match_limit) { + $match_limit = $default_match_limit; + } + + __PACKAGE__->set_sql(RecentlyUpdated => qq{ + SELECT testcase_id, summary, creation_date, last_updated + FROM testcases + WHERE last_updated>=? AND last_updated>creation_date + LIMIT $match_limit +}); + + my $err; + my $new_datestamp=&UnixDate(DateCalc("now","- $num_days days"),"%q"); + return $self->search_RecentlyUpdated($new_datestamp); } ######################################################################### @@ -151,46 +204,51 @@ sub getDefaultRelevanceThreshold() { return $default_relevance_threshold; } +######################################################################### +sub getDefaultNumDays() { + return $default_num_days; +} + ######################################################################### sub clone() { my $self = shift; - + my $new_testcase = $self->copy; - if (!$new_testcase) { + if (!$new_testcase) { return undef; } - + # Update dates to now. my $now = &UnixDate("today","%q"); $new_testcase->creation_date($now); $new_testcase->last_updated($now); $new_testcase->update(); - + # Propagate subgroup membership; - my $dbh = __PACKAGE__->db_Main(); + my $dbh = __PACKAGE__->db_Main(); my $sql = "INSERT INTO testcase_subgroups (testcase_id,subgroup_id,sort_order) SELECT ?,subgroup_id,sort_order FROM testcase_subgroups WHERE testcase_id=?"; - my $rows = $dbh->do($sql, + my $rows = $dbh->do($sql, undef, $new_testcase->testcase_id, $self->testcase_id ); if (! $rows) { # XXX: Do we need to throw a warning here? - # What happens when we clone a testcase that doesn't belong to + # What happens when we clone a testcase that doesn't belong to # any subgroups? - } - + } + $sql = "INSERT INTO related_testcases (testcase_id, related_testcase_id) VALUES (?,?)"; $rows = $dbh->do($sql, - undef, - $self->testcase_id, - $new_testcase->testcase_id - ); + undef, + $self->testcase_id, + $new_testcase->testcase_id + ); if (! $rows) { # XXX: Do we need to throw a warning here? - } - + } + return $new_testcase; } @@ -198,7 +256,7 @@ sub clone() { sub delete_from_subgroups() { my $self = shift; - my $dbh = __PACKAGE__->db_Main(); + my $dbh = __PACKAGE__->db_Main(); my $sql = "DELETE from testcase_subgroups WHERE testcase_id=?"; my $rows = $dbh->do($sql, undef, @@ -209,8 +267,8 @@ sub delete_from_subgroups() { ######################################################################### sub delete_from_related() { my $self = shift; - - my $dbh = __PACKAGE__->db_Main(); + + my $dbh = __PACKAGE__->db_Main(); my $sql = "DELETE from related_testcases WHERE testcase_id=? OR related_testcase_id=?"; my $rows = $dbh->do($sql, undef, @@ -235,7 +293,7 @@ sub update_subgroups() { if (scalar @$new_subgroup_ids) { # Failing to delete subgroups is _not_ fatal when adding a new testcase. my $rv = $self->delete_from_subgroups(); - my $dbh = __PACKAGE__->db_Main(); + my $dbh = __PACKAGE__->db_Main(); my $sql = "INSERT INTO testcase_subgroups (testcase_id,subgroup_id,sort_order) VALUES (?,?,1)"; foreach my $new_subgroup_id (@$new_subgroup_ids) { my $rows = $dbh->do($sql, diff --git a/webtools/litmus/css/litmus.css b/webtools/litmus/css/litmus.css index db50f3980ac8..1445d2f22af2 100755 --- a/webtools/litmus/css/litmus.css +++ b/webtools/litmus/css/litmus.css @@ -1232,9 +1232,29 @@ table.testcase-search th, table.test-runs th { border: 0; } +table.testcases th, table.testcases td.headerleft { + vertical-align: middle; + font-weight: bold; + text-transform: lowercase; + color: #666666; + padding: 0px 5px 0px 5px; + border: 0; +} + +table.testcases td.headerleft { + text-align: left; +} + +table.testcases tr { + border: solid #bbbbbb 1px; +} + div.testcase-search { margin: 5px; background-color: #efefef; padding: 10px; border: solid #bbbbbb 1px; } + + + diff --git a/webtools/litmus/show_test.cgi b/webtools/litmus/show_test.cgi index 2c328775c466..5e062f881817 100755 --- a/webtools/litmus/show_test.cgi +++ b/webtools/litmus/show_test.cgi @@ -47,6 +47,7 @@ $vars->{"defaultemail"} = $cookie; $vars->{"show_admin"} = Litmus::Auth::istrusted($cookie); $vars->{'default_match_limit'} = Litmus::DB::Testcase->getDefaultMatchLimit(); +$vars->{'default_num_days'} = Litmus::DB::Testcase->getDefaultNumDays(); $vars->{'default_relevance_threshold'} = Litmus::DB::Testcase->getDefaultRelevanceThreshold(); if (! $c->param) { @@ -116,7 +117,7 @@ if ($c->param("id")) { $vars->{'onload'} = "toggleMessage('$status','$message');"; } } elsif ($c->param("editingTestcases") && - ! Litmus::Auth::canEdit(Litmus::Auth::getCookie())) { + ! Litmus::Auth::canEdit(Litmus::Auth::getCookie())) { invalidInputError("You do not have permissions to edit testcases. "); } @@ -162,8 +163,29 @@ if ($c->param("text_snippet")) { $relevance_threshold); $vars->{'testcases'} = \@testcases; $vars->{'search_string_for_display'} = "Full-Text Search: \"$text_snippet\""; + $vars->{'fulltext'} = 1; +} elsif ($c->param("recently")) { + my $recently = $c->param("recently"); + my $match_limit = $c->param("match_limit"); + my $num_days = $c->param("num_days") || Litmus::DB::Testcase->getDefaultNumDays(); + my @testcases; + my $search_string_for_display; + if ($recently eq 'added') { + @testcases = Litmus::DB::Testcase->getNewTestcases( + $num_days, + $match_limit + ); + $search_string_for_display = "Testcases added in the last $num_days days"; + } elsif ($recently eq 'changed') { + @testcases = Litmus::DB::Testcase->getRecentlyUpdated( + $num_days, + $match_limit + ); + $search_string_for_display = "Testcases changed in the last $num_days days"; + } + $vars->{'testcases'} = \@testcases; + $vars->{'search_string_for_display'} = $search_string_for_display; } Litmus->template()->process("show/search_for_testcases.tmpl", $vars) || internalError(Litmus->template()->error()); - diff --git a/webtools/litmus/templates/en/default/global/litmus_footer.tmpl b/webtools/litmus/templates/en/default/global/litmus_footer.tmpl index 95da0497af15..c4f4d49c7177 100644 --- a/webtools/litmus/templates/en/default/global/litmus_footer.tmpl +++ b/webtools/litmus/templates/en/default/global/litmus_footer.tmpl @@ -26,7 +26,7 @@ #%] diff --git a/webtools/litmus/templates/en/default/show/search_for_testcases.tmpl b/webtools/litmus/templates/en/default/show/search_for_testcases.tmpl index b8c03b6bb71d..802b3abe322b 100755 --- a/webtools/litmus/templates/en/default/show/search_for_testcases.tmpl +++ b/webtools/litmus/templates/en/default/show/search_for_testcases.tmpl @@ -32,15 +32,20 @@ [% title="View Testcase" %] -[% INCLUDE global/html_header.tmpl %] +[% INCLUDE global/html_header.tmpl js_files=['js/Help.js'] %] [% INCLUDE global/litmus_header.tmpl %]
@@ -51,56 +56,23 @@ function init()

[% title | html %]

-
+
-
-Search by Testcase ID # + + + + + + + + + + + + +
-
- - - - - - - - - - -
Testcase ID#:
- - -
- -
OR
- -
-Full-text Search -
-
- -
- - - - - - - - - - - - - - - - -
String to match:
# of Matches:
Minimum Relevance Score:
-
- -
-
[% IF testcases %]

Matching Testcases[% IF search_string_for_display %] - [% search_string_for_display | html %][% END %]

@@ -119,4 +91,4 @@ Full-text Search
[% INCLUDE global/litmus_footer.tmpl %] -[% INCLUDE global/html_footer.tmpl %] \ No newline at end of file +[% INCLUDE global/html_footer.tmpl %] diff --git a/webtools/litmus/templates/en/default/show/testcase_list.tmpl b/webtools/litmus/templates/en/default/show/testcase_list.tmpl index 8267c50677c8..5ea51523b2e5 100755 --- a/webtools/litmus/templates/en/default/show/testcase_list.tmpl +++ b/webtools/litmus/templates/en/default/show/testcase_list.tmpl @@ -31,14 +31,16 @@ - + [% IF fulltext %][% END %] + + [% IF testcases.size==0 %] - + [% ELSE %] [% FOREACH testcase=testcases %] @@ -48,11 +50,13 @@ [% rowstyle = 'odd' %] [% END %] - +[% IF fulltext %][% END %] + + [% END %] [% END %] -
RelevanceRelevanceTestcase ID# NameCreation DateLast Updated
No matching testcases were found.No matching testcases were found.
[% testcase.relevance | html | format('%.2f') %][% testcase.relevance | html | format('%.2f') %][% testcase.testcase_id | html %] [% testcase.summary | html %][% testcase.creation_date | html %][% testcase.last_updated | html %]
\ No newline at end of file +