Author: rob
Date: Fri Apr  1 07:40:06 2011
New Revision: 26651
URL: https://svn.nixos.org/websvn/nix/?rev=26651&sc=1

Log:
qualify ordery_by clauses when necessary, remove unnecessary order_by's, 
reported by Ludo, resulted in errors in sqlite

Modified:
   hydra/trunk/src/lib/Hydra/Controller/Admin.pm
   hydra/trunk/src/lib/Hydra/Controller/Root.pm
   hydra/trunk/src/script/hydra_update_gc_roots.pl.in

Modified: hydra/trunk/src/lib/Hydra/Controller/Admin.pm
==============================================================================
--- hydra/trunk/src/lib/Hydra/Controller/Admin.pm       Fri Apr  1 03:17:55 
2011        (r26650)
+++ hydra/trunk/src/lib/Hydra/Controller/Admin.pm       Fri Apr  1 07:40:06 
2011        (r26651)
@@ -17,7 +17,7 @@
 sub nixMachines {
     my ($c) = @_;
     my $result = "# GENERATED BY HYDRA\n";
-       
+
     foreach my $machine ($c->model("DB::BuildMachines")->all) {
        if($machine->enabled) {
                $result = $result . $machine->username . '@'. 
$machine->hostname . ' ';
@@ -38,7 +38,7 @@
 
     open (NIXMACHINES, '>/etc/nix.machines') or die("Could not write to 
/etc/nix.machines");
     print NIXMACHINES nixMachines($c);
-    close (NIXMACHINES);     
+    close (NIXMACHINES);
 }
 
 sub admin : Chained('/') PathPart('admin') CaptureArgs(0) {
@@ -50,19 +50,19 @@
 sub index : Chained('admin') PathPart('') Args(0) {
     my ($self, $c) = @_;
     $c->stash->{machines} = [$c->model('DB::BuildMachines')->search(
-        {}, 
+        {},
         { order_by => ["enabled DESC", "hostname"]
         , '+select' => ["(select bs.stoptime from buildsteps as bs where 
bs.machine = (me.username || '\@' || me.hostname) and not bs.stoptime is null 
order by bs.stoptime desc limit 1)"]
         , '+as' => ['idle']
         })];
     $c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
         { 'me.busy' => 1, 'schedulingInfo.busy' => 1 },
-        { join => [ 'schedulingInfo', 'build' ] 
-        , order_by => [ 'machine', 'outpath' ]
+        { join => [ 'schedulingInfo', 'build' ]
+        , order_by => [ 'machine' ]
         } ) ];
     $c->stash->{template} = 'admin.tt';
  }
- 
+
 sub updateUser {
     my ($c, $user) = @_;
 
@@ -70,8 +70,8 @@
     my $fullname     = trim $c->request->params->{"fullname"};
     my $emailaddress = trim $c->request->params->{"emailaddress"};
     my $emailonerror = trim $c->request->params->{"emailonerror"};
-    my $roles         = $c->request->params->{"roles"} ; 
-    
+    my $roles         = $c->request->params->{"roles"} ;
+
     $user->update(
         { fullname => $fullname
         , emailaddress => $emailaddress
@@ -81,10 +81,10 @@
     if(ref($roles) eq 'ARRAY') {
         for my $s (@$roles) {
             $user->userroles->create({ role => $s}) ;
-        }       
+        }
     } else {
         $user->userroles->create({ role => $roles}) if defined $roles ;
-    }   
+    }
 }
 
 sub user : Chained('admin') PathPart('user') CaptureArgs(1) {
@@ -123,11 +123,11 @@
 }
 
 sub sendemail {
-   my ($to, $subject, $body) = @_; 
-   
+   my ($to, $subject, $body) = @_;
+
    my $url = hostname_long;
    my $sender = ($ENV{'USER'} || "hydra") .  "@" . $url;
-   
+
    my $email = Email::Simple->create(
         header => [
             To      => $to,
@@ -145,7 +145,7 @@
 
     # generate password
     my $password = Crypt::RandPasswd->word(8,10);
-    
+
     # calculate hash
     my $hashed = sha1_hex($password);
 
@@ -154,7 +154,7 @@
     # send email
 
     sendemail(
-        $c->user->emailaddress, 
+        $c->user->emailaddress,
         "New password for Hydra",
         "Hi,\n\n".
         "Your password has been reset. Your new password is '$password'.\n".
@@ -213,13 +213,13 @@
     my $speedfactor   = trim $c->request->params->{"speedfactor"};
     my $ssh_key       = trim $c->request->params->{"ssh_key"};
     my $options       = trim $c->request->params->{"options"};
-    my $systems       = $c->request->params->{"systems"} ; 
-       
+    my $systems       = $c->request->params->{"systems"} ;
+
     error($c, "Invalid or empty username.") if $username eq "";
     error($c, "Max concurrent builds should be an integer > 0.") if 
$maxconcurrent eq "" || ! $maxconcurrent =~ m/[0-9]+/;
     error($c, "Speed factor should be an integer > 0.") if $speedfactor eq "" 
|| ! $speedfactor =~ m/[0-9]+/;
     error($c, "Invalid or empty SSH key.") if $ssh_key eq "";
-       
+
     $machine->update(
         { username => $username
         , maxconcurrent => $maxconcurrent
@@ -231,17 +231,17 @@
     if(ref($systems) eq 'ARRAY') {
            for my $s (@$systems) {
                $machine->buildmachinesystemtypes->create({ system => $s}) ;
-           }       
+           }
     } else {
         $machine->buildmachinesystemtypes->create({ system => $systems}) ;
-    }   
+    }
 }
 
 sub create_machine : Chained('admin') PathPart('create-machine') Args(0) {
     my ($self, $c) = @_;
 
     requireAdmin($c);
-    
+
     $c->stash->{template} = 'machine.tt';
     $c->stash->{systemtypes} = [$c->model('DB::SystemTypes')->search({}, 
{order_by => "system"})];
     $c->stash->{edit} = 1;
@@ -253,10 +253,10 @@
     my ($self, $c) = @_;
 
     requireAdmin($c);
-    
+
     my $hostname = trim $c->request->params->{"hostname"};
     error($c, "Invalid or empty hostname.") if $hostname eq "";
-    
+
     txn_do($c->model('DB')->schema, sub {
         my $machine = $c->model('DB::BuildMachines')->create(
             { hostname => $hostname });
@@ -272,7 +272,7 @@
 
     txn_do($c->model('DB')->schema, sub {
         $c->stash->{machine}->delete;
-    });    
+    });
     saveNixMachines($c);
     $c->res->redirect("/admin/machines");
 }
@@ -304,7 +304,7 @@
 
     print "Clearing path cache\n";
     $c->model('DB::CachedPathInputs')->delete_all;
-    
+
     print "Clearing git cache\n";
     $c->model('DB::CachedGitInputs')->delete_all;
 
@@ -322,17 +322,17 @@
 
     $c->stash->{newsItems} = [$c->model('DB::NewsItems')->search({}, {order_by 
=> 'createtime DESC'})];
 
-    $c->stash->{template} = 'news.tt';    
+    $c->stash->{template} = 'news.tt';
 }
 
 sub news_submit : Chained('admin') Path('news/submit') Args(0) {
     my ($self, $c) = @_;
 
     requirePost($c);
-    
+
     my $contents = trim $c->request->params->{"contents"};
     my $createtime = time;
-    
+
     $c->model('DB::NewsItems')->create({
         createtime => $createtime,
         contents => $contents,
@@ -350,13 +350,13 @@
           or notFound($c, "Newsitem with id $id doesn't exist.");
         $newsItem->delete;
     });
-        
+
     $c->res->redirect("/admin/news");
 }
 
 sub force_eval : Chained('admin') Path('eval') Args(2) {
     my ($self, $c, $projectName, $jobsetName) = @_;
-    
+
     my $project = $c->model('DB::Projects')->find($projectName)
         or notFound($c, "Project $projectName doesn't exist.");
 
@@ -364,9 +364,9 @@
     $c->stash->{jobset_} = $project->jobsets->search({name => $jobsetName});
     $c->stash->{jobset} = $c->stash->{jobset_}->single
         or notFound($c, "Jobset $jobsetName doesn't exist.");
-    
+
     (my $res, my $stdout, my $stderr) = captureStdoutStderr(60, 
("hydra_evaluator.pl", $projectName, $jobsetName));
-            
+
     $c->res->redirect("/project/$projectName");
 }
 

Modified: hydra/trunk/src/lib/Hydra/Controller/Root.pm
==============================================================================
--- hydra/trunk/src/lib/Hydra/Controller/Root.pm        Fri Apr  1 03:17:55 
2011        (r26650)
+++ hydra/trunk/src/lib/Hydra/Controller/Root.pm        Fri Apr  1 07:40:06 
2011        (r26651)
@@ -15,7 +15,7 @@
     my ($self, $c, @args) = @_;
     $c->stash->{curUri} = $c->request->uri;
     $c->stash->{version} = $ENV{"HYDRA_RELEASE"} || "<devel>";
-    $c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || "<devel>";    
+    $c->stash->{nixVersion} = $ENV{"NIX_RELEASE"} || "<devel>";
     $c->stash->{curTime} = time;
 
     if (scalar(@args) == 0 || $args[0] ne "static") {
@@ -37,7 +37,7 @@
 
 sub login :Local {
     my ($self, $c) = @_;
-    
+
     my $username = $c->request->params->{username} || "";
     my $password = $c->request->params->{password} || "";
 
@@ -58,7 +58,7 @@
         }
         $c->stash->{errorMsg} = "Bad username or password.";
     }
-    
+
     $c->stash->{template} = 'login.tt';
 }
 
@@ -82,7 +82,7 @@
 sub timeline :Local {
     my ($self, $c) = @_;
     my $pit = time();
-    $c->stash->{pit} = $pit; 
+    $c->stash->{pit} = $pit;
     $pit = $pit-(24*60*60)-1;
 
     $c->stash->{template} = 'timeline.tt';
@@ -90,8 +90,8 @@
         {finished => 1, stoptime => { '>' => $pit } }
       , { join => 'resultInfo'
         , order_by => ["starttime"]
-        , '+select' => [ 'resultInfo.starttime', 'resultInfo.stoptime', 
'resultInfo.buildstatus' ]   
-        , '+as' => [ 'starttime', 'stoptime', 'buildstatus' ]   
+        , '+select' => [ 'resultInfo.starttime', 'resultInfo.stoptime', 
'resultInfo.buildstatus' ]
+        , '+as' => [ 'starttime', 'stoptime', 'buildstatus' ]
         })];
 }
 
@@ -100,8 +100,8 @@
     my ($self, $c) = @_;
     $c->stash->{steps} = [ $c->model('DB::BuildSteps')->search(
         { 'me.busy' => 1, 'schedulingInfo.busy' => 1 },
-        { join => [ 'schedulingInfo', 'build' ] 
-        , order_by => [ 'machine', 'outpath' ]
+        { join => [ 'schedulingInfo', 'build' ]
+        , order_by => [ 'machine' ]
         } ) ];
 }
 
@@ -158,12 +158,12 @@
         , channelUris('Job', ["*", "*", "*", "*"])
         , channelUris('Build', ["*"])
         );
-    
+
     $c->stash->{'plain'} = { data => "User-agent: *\n" . join('', map { 
"Disallow: $_\n" } @rules) };
     $c->forward('Hydra::View::Plain');
 }
 
-    
+
 sub default :Path {
     my ($self, $c) = @_;
     notFound($c, "Page not found.");
@@ -201,27 +201,27 @@
 
 sub change_password : Path('change-password') : Args(0) {
     my ($self, $c) = @_;
-    
+
     requireLogin($c) if !$c->user_exists;
-    
-    $c->stash->{template} = 'change-password.tt';   
+
+    $c->stash->{template} = 'change-password.tt';
 }
 
 sub change_password_submit : Path('change-password/submit') : Args(0) {
     my ($self, $c) = @_;
-    
+
     requireLogin($c) if !$c->user_exists;
-    
-    my $password = $c->request->params->{"password"}; 
+
+    my $password = $c->request->params->{"password"};
     my $password_check = $c->request->params->{"password_check"};
     print STDERR "$password \n";
     print STDERR "$password_check \n";
     error($c, "Passwords did not match, go back and try again!") if $password 
ne $password_check;
-    
+
     my $hashed = sha1_hex($password);
     $c->user->update({ password => $hashed}) ;
-    
-    $c->res->redirect("/");    
+
+    $c->res->redirect("/");
 }
 
 1;

Modified: hydra/trunk/src/script/hydra_update_gc_roots.pl.in
==============================================================================
--- hydra/trunk/src/script/hydra_update_gc_roots.pl.in  Fri Apr  1 03:17:55 
2011        (r26650)
+++ hydra/trunk/src/script/hydra_update_gc_roots.pl.in  Fri Apr  1 07:40:06 
2011        (r26651)
@@ -46,12 +46,12 @@
             print STDERR "*** skipping disabled jobset ", $project->name, ":", 
$jobset->name, "\n";
             next;
         }
-        
+
         if ($keepnr <= 0 ) {
             print STDERR "*** jobset ", $project->name, ":", $jobset->name, " 
set to keep 0 builds\n";
             next;
         }
-        
+
         # Go over all jobs in this jobset.
         foreach my $job ($jobset->jobs->all) {
             print STDERR "*** looking for builds to keep in job ",
@@ -69,7 +69,7 @@
                     , system => $system->system
                     },
                     { join => 'resultInfo'
-                    , order_by => 'id DESC'
+                    , order_by => 'me.id DESC'
                     , rows => $keepnr
                     });
                 keepBuild $_ foreach @recentBuilds;
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to