Files
handbrake-cluster-webui/HandBrakeCluster/JobStatus.class.php
Ben Roberts a9ebf6e0cb Core class updates
Improved database abstraction class to support insert and select queries
in various forms.
Added classes for pulling log entries back out of the database.
Updated Job class to describe a known job in the database, and added
JobStatus to track status updates on jobs.
Updated Config class to connect to the database, and load all settings
on startup.
Improved the class autoloader to support Exceptions in a single file as
a special case, and added this file.
2010-03-18 02:00:53 +00:00

74 lines
1.7 KiB
PHP

<?php
class HandBrakeCluster_JobStatus {
const QUEUED = 0;
const FAILED = 1;
const RUNNING = 2;
const COMPLETE = 3;
private static $status_names = array(
self::QUEUED => 'Queued',
self::FAILED => 'Failed',
self::RUNNING => 'Running',
self::COMPLETE => 'Complete'
);
protected $id;
protected $job_id;
protected $status;
protected $ctime;
protected function __construct($id, $job_id, $status, $ctime) {
$this->id = $id;
$this->job_id = $job_id;
$this->status = $status;
$this->ctime = $ctime;
}
public static function fromDatabaseRow($row) {
return new HandBrakeCluster_JobStatus(
$row['id'],
$row['job_id'],
$row['status'],
$row['ctime']
);
}
public static function allForJob($job_id) {
$statuses = array();
$database = HandBrakeCluster_Main::instance()->database();
foreach ($database->selectList('SELECT * FROM job_status WHERE job_id=:job_id ORDER BY ctime ASC', array(
array('name' => 'job_id', 'value' => $job_id, 'type' => PDO::PARAM_INT),
)) as $row) {
$statuses[] = HandBrakeCluster_JobStatus::fromDatabaseRow($row);
}
return $statuses;
}
public function id() {
return $this->id;
}
public function jobId() {
return $this->job_id;
}
public function status() {
return $this->status;
}
public function statusName() {
return self::$status_names[$this->status];
}
public function ctime() {
return $this->ctime;
}
};
?>