7 Fumo::Queue - Manipulate a queue of smoke server runs.
11 Queue holds a queue of test runs that are to be run. It allows
12 manipulation of a weight field so that users can change which runs
23 =item Return Value: $self
27 Initialises a new Fumo::Queue object.
32 my ($class, $dbh) = @_;
49 =item Return Value: none
53 Empties the queue completely. Will croak on failure.
60 if (not defined $self->{all_sth
}) {
61 $self->{all_sth
} = $self->{dbh
}->prepare(qq(
70 $self->{all_sth
}->execute()
71 or croak
$self->{dbh
}->errstr();
74 my $details = $self->{all_sth
}->fetchrow_hashref();
76 if (defined $details) {
77 return Fumo
::Queue
::Run
->new($details)
80 return $self->{all_sth
} = undef;
90 =item Return Value: none
94 Empties the queue completely. Will croak on failure.
105 )) or croak
$self->{dbh
}->errstr();
112 =item Arguments: none
114 =item Return Value: Queue count
118 Returns the number of runs in the queue. Croaks should there be a problem.
125 my $sth = $self->{dbh
}->prepare(q
(
127 count
(project
) as count
130 )) or croak
$self->{dbh
}->errstr();
133 or croak
$self->{dbh
}->errstr();
135 return $sth->fetchrow_hashref->{count
};
142 =item Arguments: Queue::Run object
144 =item Return Value: none
148 Add a Queue::Run object to the queue.
153 my ($self, $run) = @_;
155 # does it this run already exist?
156 if (not $self->get_run($run->project, $run->branch, $run->revision)) {
157 my $sth = $self->{dbh
}->prepare(q
(
159 queue
(project
, branch
, revision
, created
)
162 )) or croak
$self->{dbh
}->errstr;
164 $sth->execute($run->project, $run->branch, $run->revision)
165 or croak
$self->{dbh
}->errstr;
168 my $sth = $self->{dbh
}->prepare(q
(
172 created
= ?
, run_start
= ?
, weight
= ?
, status
= ?
, comment
= ?
174 project
= ? AND branch
= ? AND revision
= ?
177 # grab the argument from the Fumo::Queue::Run
184 } qw(created run_start weight status comment project branch
189 or croak
$self->{dbh
}->errstr;
197 =item Arguments: Queue::Run
199 =item Return Value: none
203 Delete the Queue::Run object given (it must have at least project,
204 branch and revision attributes).
209 my ($self, $run) = @_;
211 my $sth = $self->{dbh
}->prepare(q
(
216 project
= ? AND branch
= ? AND revision
= ?
217 )) or croak
$self->{dbh
}->errstr();
219 $sth->execute($run->project, $run->branch, $run->revision)
220 or croak
$self->{dbh
}->errstr;
227 =item Arguments: $project, $branch, $revision
229 =item Return Value: Queue::Run
233 Grab the Queue::Run object with the project, branch and revision.
238 my ($self, $project, $branch, $revision) = @_;
240 my $sth = $self->{dbh
}->prepare(q
(
246 project
= ? AND branch
= ? AND revision
= ?
247 )) or croak
$self->{dbh
}->errstr;
249 $sth->execute($project, $branch, $revision)
250 or croak
$self->{dbh
}->errstr;
252 my $details = $sth->fetchrow_hashref();
254 return (defined $details)
255 ? Fumo
::Queue
::Run
->new($details)