From 208bbf31e9c76998825673b8b5ef8033ab28d5ef Mon Sep 17 00:00:00 2001 From: "zach%zachlipton.com" Date: Sat, 20 Aug 2005 03:39:02 +0000 Subject: [PATCH] Land Coop's new schema. This makes some pretty wideranging changes and there's no upgrade path, so to upgrade from a previous db, wipe your database and start over. Schema changes by coop, Class::DBI wrangling by me. --- webtools/litmus/Litmus/Config.pm | 2 +- webtools/litmus/Litmus/DB/Branch.pm | 5 +- webtools/litmus/Litmus/DB/Format.pm | 6 +- webtools/litmus/Litmus/DB/Opsys.pm | 5 +- webtools/litmus/Litmus/DB/Platform.pm | 5 +- webtools/litmus/Litmus/DB/Product.pm | 4 +- webtools/litmus/Litmus/DB/Result.pm | 6 +- webtools/litmus/Litmus/DB/Status.pm | 6 +- webtools/litmus/Litmus/DB/Subgroup.pm | 5 +- webtools/litmus/Litmus/DB/Test.pm | 22 ++- webtools/litmus/Litmus/DB/Testgroup.pm | 8 +- webtools/litmus/Litmus/DB/Testresult.pm | 34 +++- webtools/litmus/Litmus/DB/User.pm | 5 +- webtools/litmus/Litmus/DBI.pm | 46 +++++ webtools/litmus/Litmus/UserAgentDetect.pm | 4 +- webtools/litmus/createdb.sql | 197 ++++++++++++++++------ webtools/litmus/process_test.cgi | 11 +- webtools/litmus/simpletest.cgi | 31 ++-- 18 files changed, 307 insertions(+), 95 deletions(-) diff --git a/webtools/litmus/Litmus/Config.pm b/webtools/litmus/Litmus/Config.pm index f42b91bf8323..71d195388656 100755 --- a/webtools/litmus/Litmus/Config.pm +++ b/webtools/litmus/Litmus/Config.pm @@ -25,7 +25,7 @@ use strict; do 'localconfig'; -our $version = "0.0.1"; +our $version = "0.0.2"; # if true, then Litmus will not accept any requests our $disabled = 0; diff --git a/webtools/litmus/Litmus/DB/Branch.pm b/webtools/litmus/Litmus/DB/Branch.pm index b7166862813e..592517252cb3 100755 --- a/webtools/litmus/Litmus/DB/Branch.pm +++ b/webtools/litmus/Litmus/DB/Branch.pm @@ -26,7 +26,10 @@ use base 'Litmus::DBI'; Litmus::DB::Branch->table('branches'); -Litmus::DB::Branch->columns(All => qw/branchid product name detect_regexp/); +Litmus::DB::Branch->columns(All => qw/branch_id product_id name detect_regexp/); + +Litmus::DB::Branch->column_alias("branch_id", "branchid"); +Litmus::DB::Branch->column_alias("product_id", "product"); Litmus::DB::Branch->has_many(testresults => "Litmus::DB::Testresult"); Litmus::DB::Branch->has_a(product => "Litmus::DB::Product"); diff --git a/webtools/litmus/Litmus/DB/Format.pm b/webtools/litmus/Litmus/DB/Format.pm index e5cc947ef9eb..cb90b8f95f93 100755 --- a/webtools/litmus/Litmus/DB/Format.pm +++ b/webtools/litmus/Litmus/DB/Format.pm @@ -28,9 +28,11 @@ use IO::File; use Litmus::Error; use Litmus; -Litmus::DB::Format->table('formats'); +Litmus::DB::Format->table('test_format_lookup'); -Litmus::DB::Format->columns(All => qw/formatid name/); +Litmus::DB::Format->columns(All => qw/format_id name/); + +Litmus::DB::Format->column_alias("format_id", "formatid"); Litmus::DB::Format->has_many(tests => "Litmus::DB::Test"); diff --git a/webtools/litmus/Litmus/DB/Opsys.pm b/webtools/litmus/Litmus/DB/Opsys.pm index ec20bf985a1a..125585c2dc55 100755 --- a/webtools/litmus/Litmus/DB/Opsys.pm +++ b/webtools/litmus/Litmus/DB/Opsys.pm @@ -26,7 +26,10 @@ use base 'Litmus::DBI'; Litmus::DB::Opsys->table('opsyses'); -Litmus::DB::Opsys->columns(All => qw/opsysid platform name detect_regexp/); +Litmus::DB::Opsys->columns(All => qw/opsys_id platform_id name detect_regexp/); + +Litmus::DB::Opsys->column_alias("opsys_id", "opsysid"); +Litmus::DB::Opsys->column_alias("platform_id", "platform"); Litmus::DB::Opsys->has_many(testresults => "Litmus::DB::Testresult"); Litmus::DB::Opsys->has_a(platform => "Litmus::DB::Platform"); diff --git a/webtools/litmus/Litmus/DB/Platform.pm b/webtools/litmus/Litmus/DB/Platform.pm index 053684abeeec..c9369f4eb770 100755 --- a/webtools/litmus/Litmus/DB/Platform.pm +++ b/webtools/litmus/Litmus/DB/Platform.pm @@ -27,7 +27,10 @@ use CGI; Litmus::DB::Platform->table('platforms'); -Litmus::DB::Platform->columns(All => qw/platformid product name detect_regexp iconpath/); +Litmus::DB::Platform->columns(All => qw/platform_id product_id name detect_regexp iconpath/); + +Litmus::DB::Platform->column_alias("platform_id", "platformid"); +Litmus::DB::Platform->column_alias("product_id", "product"); Litmus::DB::Platform->has_a(product => "Litmus::DB::Product"); Litmus::DB::Platform->has_many(testresults => "Litmus::DB::Testresult"); diff --git a/webtools/litmus/Litmus/DB/Product.pm b/webtools/litmus/Litmus/DB/Product.pm index b325485794db..055f6a5731f7 100755 --- a/webtools/litmus/Litmus/DB/Product.pm +++ b/webtools/litmus/Litmus/DB/Product.pm @@ -26,7 +26,9 @@ use base 'Litmus::DBI'; Litmus::DB::Product->table('products'); -Litmus::DB::Product->columns(All => qw/productid name iconpath/); +Litmus::DB::Product->columns(All => qw/product_id name iconpath/); + +Litmus::DB::Product->column_alias("product_id", "productid"); Litmus::DB::Product->has_many(tests => "Litmus::DB::Test"); Litmus::DB::Product->has_many(testgroups => "Litmus::DB::Testgroup"); diff --git a/webtools/litmus/Litmus/DB/Result.pm b/webtools/litmus/Litmus/DB/Result.pm index a291009982e5..8d4d31d3e174 100755 --- a/webtools/litmus/Litmus/DB/Result.pm +++ b/webtools/litmus/Litmus/DB/Result.pm @@ -24,9 +24,11 @@ package Litmus::DB::Result; use strict; use base 'Litmus::DBI'; -Litmus::DB::Result->table('results'); +Litmus::DB::Result->table('test_result_status_lookup'); -Litmus::DB::Result->columns(All => qw/resultid name style/); +Litmus::DB::Result->columns(All => qw/result_status_id name style/); + +Litmus::DB::Result->column_alias("result_status_id", "resultid"); Litmus::DB::Result->has_many(testresults => "Litmus::DB::Testresult"); diff --git a/webtools/litmus/Litmus/DB/Status.pm b/webtools/litmus/Litmus/DB/Status.pm index a0e6765f3235..6c72a692783e 100755 --- a/webtools/litmus/Litmus/DB/Status.pm +++ b/webtools/litmus/Litmus/DB/Status.pm @@ -24,9 +24,11 @@ package Litmus::DB::Status; use strict; use base 'Litmus::DBI'; -Litmus::DB::Status->table('statuses'); +Litmus::DB::Status->table('test_status_lookup'); -Litmus::DB::Status->columns(All => qw/statusid name/); +Litmus::DB::Status->columns(All => qw/test_status_id name/); + +Litmus::DB::Status->column_alias("test_status_id", "statusid"); Litmus::DB::Status->has_many(tests => "Litmus::DB::Test"); diff --git a/webtools/litmus/Litmus/DB/Subgroup.pm b/webtools/litmus/Litmus/DB/Subgroup.pm index 0b5eedfb76e6..84f12f01ba9f 100755 --- a/webtools/litmus/Litmus/DB/Subgroup.pm +++ b/webtools/litmus/Litmus/DB/Subgroup.pm @@ -30,7 +30,10 @@ use Litmus::DB::Testresult; Litmus::DB::Subgroup->table('subgroups'); -Litmus::DB::Subgroup->columns(All => qw/subgroupid testgroup name/); +Litmus::DB::Subgroup->columns(All => qw/subgroup_id testgroup_id name/); + +Litmus::DB::Subgroup->column_alias("subgroup_id", "subgroupid"); +Litmus::DB::Subgroup->column_alias("testgroup_id", "testgroup"); Litmus::DB::Subgroup->has_a(testgroup => "Litmus::DB::Testgroup"); diff --git a/webtools/litmus/Litmus/DB/Test.pm b/webtools/litmus/Litmus/DB/Test.pm index efed120e7e24..4d500154588e 100755 --- a/webtools/litmus/Litmus/DB/Test.pm +++ b/webtools/litmus/Litmus/DB/Test.pm @@ -30,15 +30,21 @@ use Litmus::Error; Litmus::DB::Test->table('tests'); -Litmus::DB::Test->columns(Primary => qw/testid/); -Litmus::DB::Test->columns(Essential => qw/testid subgroup summary status communityenabled format/); -Litmus::DB::Test->columns(All => qw/t1 t2 t3 s1 s2 i1 i2/); +Litmus::DB::Test->columns(Primary => qw/test_id/); +Litmus::DB::Test->columns(Essential => qw/subgroup_id summary details status_id community_enabled format_id regression_bug_id/); +Litmus::DB::Test->columns(All => qw/t1 t2 t3/); + +Litmus::DB::Test->column_alias("test_id", "testid"); +Litmus::DB::Test->column_alias("subgroup_id", "subgroup"); +Litmus::DB::Test->column_alias("status_id", "status"); +Litmus::DB::Test->column_alias("community_enabled", "communityenabled"); +Litmus::DB::Test->column_alias("format_id", "format"); Litmus::DB::Test->has_a(subgroup => "Litmus::DB::Subgroup"); Litmus::DB::Test->has_a(status => "Litmus::DB::Status"); Litmus::DB::Test->has_a("format" => "Litmus::DB::Format"); -Litmus::DB::Test->has_many(testresults => "Litmus::DB::Testresult", {order_by => 'timestamp DESC'}); +Litmus::DB::Test->has_many(testresults => "Litmus::DB::Testresult", {order_by => 'submission_time DESC'}); # we override Class::DBI's find_column() so that when we refer to # formatted names like steps and expected results, we use the actual @@ -48,17 +54,17 @@ sub find_column { my $self = shift; my $want = shift; - my $col; + my $col = undef; if (ref $self) { $want =~ s/^.*::(\w+)$/$1/; - $col = $self->format()->getColumnMapping($want); + $col = $self->format_id()->getColumnMapping($want); } if ($col) { return $self->SUPER::find_column($col); } else { # didn't find it, so we fall back on the normal - # find_column: + # find_column from Litmus::DBI: $self->SUPER::find_column($want); } } @@ -74,7 +80,7 @@ sub AUTOLOAD { my $col = $self->find_column($name); if (!$col) { - internalError("tried to call Litmus::DB::Test method $name which does not exist "); + internalError("tried to call Litmus::DB::Test method $name which does not exist"); } return $self->$col(@args); diff --git a/webtools/litmus/Litmus/DB/Testgroup.pm b/webtools/litmus/Litmus/DB/Testgroup.pm index a777c5b8ed85..20328e2d179d 100755 --- a/webtools/litmus/Litmus/DB/Testgroup.pm +++ b/webtools/litmus/Litmus/DB/Testgroup.pm @@ -24,9 +24,13 @@ package Litmus::DB::Testgroup; use strict; use base 'Litmus::DBI'; -Litmus::DB::Testgroup->table('testgroups'); +Litmus::DB::Testgroup->table('test_groups'); -Litmus::DB::Testgroup->columns(All => qw/testgroupid product name expirationdays/); +Litmus::DB::Testgroup->columns(All => qw/testgroup_id product_id name expiration_days/); + +Litmus::DB::Testgroup->column_alias("testgroup_id", "testgroupid"); +Litmus::DB::Testgroup->column_alias("product_id", "product"); +Litmus::DB::Testgroup->column_alias("expiration_days", "expirationdays"); Litmus::DB::Testgroup->has_a(product => "Litmus::DB::Product"); diff --git a/webtools/litmus/Litmus/DB/Testresult.pm b/webtools/litmus/Litmus/DB/Testresult.pm index d6e3150e683a..a6e0ab1160b5 100755 --- a/webtools/litmus/Litmus/DB/Testresult.pm +++ b/webtools/litmus/Litmus/DB/Testresult.pm @@ -28,9 +28,20 @@ use Time::Piece; use Time::Seconds; use Memoize; -Litmus::DB::Testresult->table('testresults'); +Litmus::DB::Testresult->table('test_results'); -Litmus::DB::Testresult->columns(All => qw/testresultid platform opsys branch buildid useragent result note user testid timestamp/); +Litmus::DB::Testresult->columns(All => qw/testresult_id test_id last_updated submission_time user_id platform_id opsys_id branch_id buildid user_agent result_id log_id/); + +Litmus::DB::Testresult->column_alias("testresult_id", "testresultid"); +Litmus::DB::Testresult->column_alias("test_id", "testid"); +Litmus::DB::Testresult->column_alias("submission_time", "timestamp"); +Litmus::DB::Testresult->column_alias("user_id", "user"); +Litmus::DB::Testresult->column_alias("platform_id", "platform"); +Litmus::DB::Testresult->column_alias("opsys_id", "opsys"); +Litmus::DB::Testresult->column_alias("branch_id", "branch"); +Litmus::DB::Testresult->column_alias("user_agent", "useragent"); +Litmus::DB::Testresult->column_alias("result_id", "result"); +Litmus::DB::Testresult->column_alias("log_id", "log"); Litmus::DB::Testresult->has_a(platform => "Litmus::DB::Platform"); @@ -40,9 +51,28 @@ Litmus::DB::Testresult->has_a(testid => "Litmus::DB::Test"); Litmus::DB::Testresult->has_a(result => "Litmus::DB::Result"); Litmus::DB::Testresult->has_a(user => "Litmus::DB::User"); Litmus::DB::Testresult->has_a(useragent => "Litmus::UserAgentDetect"); +Litmus::DB::Testresult->has_a("log" => "Litmus::DB::Log"); + +Litmus::DB::Testresult->has_many(comments => "Litmus::DB::Comment", {order_by => 'submission_time'}); +Litmus::DB::Testresult->has_many(bugs => "Litmus::DB::Resultbug", {order_by => 'submission_time DESC'}); Litmus::DB::Testresult->autoinflate(dates => 'Time::Piece'); +# 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 result submitter" +sub note { + my $self = shift; + + my @comments = $self->comments(); + + if (@comments && @comments[0] && + @comments[0]->user() == $self->user()) { + return $comments[0]->comment(); + } else { + return undef; + } +} + # is this test result recent? memoize('isrecent', NORMALIZER => sub {my $a=shift; return $a->testresultid()}); sub isrecent { diff --git a/webtools/litmus/Litmus/DB/User.pm b/webtools/litmus/Litmus/DB/User.pm index 73b2f2a977e2..2757467dbd9f 100755 --- a/webtools/litmus/Litmus/DB/User.pm +++ b/webtools/litmus/Litmus/DB/User.pm @@ -26,7 +26,10 @@ use base 'Litmus::DBI'; Litmus::DB::User->table('users'); -Litmus::DB::User->columns(All => qw/userid email istrusted/); +Litmus::DB::User->columns(All => qw/user_id email is_trusted/); + +Litmus::DB::User->column_alias("user_id", "userid"); +Litmus::DB::User->column_alias("is_trusted", "istrusted"); Litmus::DB::User->has_many(testresults => "Litmus::DB::Testresult"); diff --git a/webtools/litmus/Litmus/DBI.pm b/webtools/litmus/Litmus/DBI.pm index 29ad3cb4fb13..2bdbfb5cd27b 100755 --- a/webtools/litmus/Litmus/DBI.pm +++ b/webtools/litmus/Litmus/DBI.pm @@ -4,16 +4,62 @@ use strict; use warnings; use Litmus::Config; use Litmus::Error; +use Memoize; use base 'Class::DBI::mysql'; my $dsn = "dbi:mysql:$Litmus::Config::db_name:$Litmus::Config::db_host"; +our %column_aliases; + Litmus::DBI->set_db('Main', $dsn, $Litmus::Config::db_user, $Litmus::Config::db_pass); +# In some cases, we have column names that make sense from a database perspective +# (i.e. subgroup_id), but that don't make sense from a class/object perspective +# (where subgroup would be more appropriate). To handle this, we allow for +# Litmus::DBI's subclasses to set column aliases with the column_alias() sub. +# Takes the database column name and the alias name. +sub column_alias { + my ($self, $db_name, $alias_name) = @_; + + $column_aliases{$alias_name} = $db_name; +} + +# here's where the actual work happens. We consult our alias list +# (as created by calls to column_alias()) and substitute the +# database column if we find a match +memoize('find_column'); +sub find_column { + my $self = shift; + my $wanted = shift; + + if (ref $self) { + $wanted =~ s/^.*::(\w+)$/$1/; + } + if ($column_aliases{$wanted}) { + return $column_aliases{$wanted}; + } else { + # not an alias, so we use the normal + # find_column() from Class::DBI + $self->SUPER::find_column($wanted); + } +} + +sub AUTOLOAD { + my $self = shift; + my @args = @_; + my $name = our $AUTOLOAD; + + my $col = $self->find_column($name); + if (!$col) { + internalEror("tried to call Litmus::DBI method $name which does not exist"); + } + + return $self->$col(@args); +} 1; diff --git a/webtools/litmus/Litmus/UserAgentDetect.pm b/webtools/litmus/Litmus/UserAgentDetect.pm index ecb270764e38..6a9a0f0802ac 100755 --- a/webtools/litmus/Litmus/UserAgentDetect.pm +++ b/webtools/litmus/Litmus/UserAgentDetect.pm @@ -40,14 +40,14 @@ Litmus::DB::Platform->set_sql(detectplatform => qq{ FROM __TABLE__ WHERE ? REGEXP detect_regexp AND - product LIKE ? + product_id LIKE ? }); Litmus::DB::Branch->set_sql(detectbranch => qq{ SELECT __ESSENTIAL__ FROM __TABLE__ WHERE ? REGEXP detect_regexp AND - product LIKE ? + product_id LIKE ? }); # constructor. Optionally you can pass a UA string diff --git a/webtools/litmus/createdb.sql b/webtools/litmus/createdb.sql index 2328158d32a5..23217c7743c0 100755 --- a/webtools/litmus/createdb.sql +++ b/webtools/litmus/createdb.sql @@ -2,94 +2,189 @@ create database litmus; use litmus; create table tests ( - testid int not null primary key auto_increment, - subgroup smallint not null, - summary varchar(255), - status tinyint not null, - communityenabled boolean, - format tinyint not null, - t1 longtext, + test_id int(11) not null primary key auto_increment, + subgroup_id smallint(6) not null, + summary varchar(255) not null, + details text, + status_id tinyint(4) not null, + community_enabled boolean, + format_id tinyint(4) not null, + regression_bug_id int(11), + t1 longtext, t2 longtext, t3 longtext, - s1 varchar(255), - s2 varchar(255), - i1 mediumint, - i2 mediumint + + INDEX(subgroup_id), + INDEX(summary), + INDEX(status_id), + INDEX(community_enabled), + INDEX(format_id), + INDEX(regression_bug_id), + INDEX(t1(255)), + INDEX(t2(255)), + INDEX(t3(255)) ); -create table testresults ( - testresultid int not null primary key auto_increment, - testid int not null, - timestamp datetime not null, - user int, - platform smallint, - opsys smallint, - branch smallint, +create table test_results ( + testresult_id int(11) not null primary key auto_increment, + test_id int(11) not null, + last_updated datetime not null, + submission_time datetime not null, + user_id int(11), + platform_id smallint(6), + opsys_id smallint(6), + branch_id smallint(6), buildid varchar(45), - useragent varchar(255), - result smallint, - note text + user_agent varchar(255), + result_id smallint(6), + log_id int(11), + + INDEX (test_id), + INDEX (last_updated), + INDEX (submission_time), + INDEX (user_id), + INDEX (platform_id), + INDEX (opsys_id), + INDEX (branch_id), + INDEX (user_agent), + INDEX (result_id), + INDEX (log_id) ); create table products ( - productid tinyint not null primary key auto_increment, + product_id tinyint not null primary key auto_increment, name varchar(64) not null, - iconpath varchar(64) + iconpath varchar(255), + + INDEX(name), + INDEX(iconpath) ); -create table testgroups ( - testgroupid smallint not null primary key auto_increment, - product tinyint not null, +create table test_groups ( + testgroup_id smallint(6) not null primary key auto_increment, + product_id tinyint(4) not null, name varchar(64) not null, - expirationdays smallint not null + expiration_days smallint(6) not null, + + INDEX(product_id), + INDEX(name), + INDEX(expiration_days) ); create table subgroups ( - subgroupid smallint not null primary key auto_increment, - testgroup smallint not null, - name varchar(64) not null + subgroup_id smallint(6) not null primary key auto_increment, + testgroup_id smallint(6) not null, + name varchar(64) not null, + + INDEX(testgroup_id), + INDEX(name) ); -create table statuses ( - statusid tinyint not null primary key auto_increment, - name varchar(64) not null +create table test_status_lookup ( + test_status_id tinyint(4) not null primary key auto_increment, + name varchar(64) not null, + + INDEX(name) ); create table platforms ( - platformid smallint not null primary key auto_increment, - product tinyint not null, + platform_id smallint(6) not null primary key auto_increment, + product_id tinyint(4) not null, name varchar(64) not null, detect_regexp varchar(255), - iconpath varchar(64) + iconpath varchar(255), + + INDEX(product_id), + INDEX(name), + INDEX(detect_regexp), + INDEX(iconpath) ); create table opsyses ( - opsysid smallint not null primary key auto_increment, - platform smallint not null, + opsys_id smallint(6) not null primary key auto_increment, + platform_id smallint(6) not null, name varchar(64) not null, - detect_regexp varchar(255) + detect_regexp varchar(255), + + INDEX(platform_id), + INDEX(name), + INDEX(detect_regexp) ); create table branches ( - branchid smallint not null primary key auto_increment, - product tinyint not null, + branch_id smallint(6) not null primary key auto_increment, + product_id tinyint(4) not null, name varchar(64) not null, - detect_regexp varchar(255) + detect_regexp varchar(255), + + INDEX (product_id), + INDEX (name), + INDEX (detect_regexp) ); -create table results ( - resultid smallint not null primary key auto_increment, +create table test_result_status_lookup ( + result_status_id smallint(6) not null primary key auto_increment, name varchar(64) not null, - style varchar(255) not null + style varchar(255) not null, + + INDEX(name), + INDEX(style) ); create table users ( - userid int not null primary key auto_increment, + user_id int(11) not null primary key auto_increment, email varchar(255) not null, - istrusted boolean + is_trusted boolean, + + INDEX(email), + INDEX(is_trusted) ); -create table formats ( - formatid tinyint not null primary key auto_increment, - name varchar(255) not null +create table test_format_lookup ( + format_id tinyint(4) not null primary key auto_increment, + name varchar(255) not null, + + INDEX(name) +); + +create table test_result_bugs ( + test_result_id int(11) not null auto_increment, + last_updated datetime not null, + submission_time datetime not null, + user_id int(11), + bug_id int(11), + + PRIMARY KEY (test_result_id,bug_id), + + INDEX(test_result_id), + INDEX(last_updated), + INDEX(submission_time), + INDEX(user_id) +); + +create table test_result_comments ( + comment_id int(11) not null primary key auto_increment, + test_result_id int(11) not null, + last_updated datetime not null, + submission_time datetime not null, + user_id int(11), + comment text, + + INDEX(test_result_id), + INDEX(last_updated), + INDEX(submission_time), + INDEX(user_id) +); + +create table test_result_logs ( + log_id int(11) not null primary key auto_increment, + test_result_id int(11) not null, + last_updated datetime not null, + submission_time datetime not null, + log_path varchar(255), + + INDEX(test_result_id), + INDEX(last_updated), + INDEX(submission_time), + INDEX(log_path) ); \ No newline at end of file diff --git a/webtools/litmus/process_test.cgi b/webtools/litmus/process_test.cgi index d1fea5ae1bea..6b7114212491 100755 --- a/webtools/litmus/process_test.cgi +++ b/webtools/litmus/process_test.cgi @@ -124,18 +124,25 @@ foreach my $curtestid (@tests) { $user = $user || Litmus::Auth::getCookie()->userid(); } - Litmus::DB::Testresult->create({ + my $tr = Litmus::DB::Testresult->create({ user => $user, testid => $curtest, timestamp => $time, useragent => $ua, result => $result, - note => $note, platform => $sysconfig->platform(), opsys => $sysconfig->opsys(), branch => $sysconfig->branch(), buildid => $sysconfig->buildid(), }); + + # if there's a note, create an entry in the comments table for it + Litmus::DB::Comment->create({ + testresult => $tr, + submission_time => $time, + user => $user, + comment => $note + }); } # process changes to testcases: diff --git a/webtools/litmus/simpletest.cgi b/webtools/litmus/simpletest.cgi index 5161de9cc8ce..1f5c693dd685 100755 --- a/webtools/litmus/simpletest.cgi +++ b/webtools/litmus/simpletest.cgi @@ -36,8 +36,9 @@ my $c = new CGI; # how old of a build do we want to allow? default is 10 days my $maxbuildage = 10; -# what branch do we accept? default is Deer Park +# what branch do we accept? default is the trunk or the 1.8 branch my $branch = Litmus::DB::Branch->retrieve(1); +my $branch2 = Litmus::DB::Branch->retrieve(2); showTest(); @@ -51,27 +52,27 @@ sub showTest { $time->date_separator(""); my $curbuildtime = $time->ymd; my $prod = Litmus::DB::Product->search(name => "Firefox")->next(); - my $branch = Litmus::DB::Branch->search(product => $prod, name => "Trunk")->next(); my @detectbranch = $ua->branch($prod); - if (! $ua->buildid() || ! $detectbranch[0] || - $detectbranch[0]->branchid() != $branch->branchid() || - $curbuildtime - $ua->buildid() > $maxbuildage) { - Litmus->template()->process("simpletest/simpletest.html.tmpl") || - internalError(Litmus->template()->error()); - exit; + if ((! $ua->buildid()) || (! $detectbranch[0]) || + $curbuildtime - $ua->buildid() > $maxbuildage || + ($detectbranch[0]->branchid() != $branch->branchid() && + $detectbranch[0]->branchid() != $branch2->branchid())) { + Litmus->template()->process("simpletest/simpletest.html.tmpl") || + internalError(Litmus->template()->error()); + exit; } my $pid = $prod->productid(); # get a random test to display: Litmus::DB::Test->set_sql(random_test => qq { - SELECT __ESSENTIAL__ - FROM __TABLE__, products,testgroups,subgroups + SELECT tests.test_id, tests.subgroup_id, tests.summary, tests.details, tests.status_id, tests.community_enabled, tests.format_id, tests.regression_bug_id + FROM __TABLE__, products,test_groups,subgroups WHERE - products.productid=? AND - communityenabled = 1 AND - products.productid=testgroups.product AND - subgroups.testgroup=testgroups.testgroupid AND - tests.subgroup=subgroups.subgroupid + products.product_id=? AND + community_enabled = 1 AND + products.product_id=test_groups.product_id AND + subgroups.testgroup_id=test_groups.testgroup_id AND + tests.subgroup_id=subgroups.subgroup_id ORDER BY RAND() LIMIT 1 });