diff --git a/src/applications/harbormaster/constants/HarbormasterBuildStatus.php b/src/applications/harbormaster/constants/HarbormasterBuildStatus.php index 341bf4b7ab..a2cdba5b63 100644 --- a/src/applications/harbormaster/constants/HarbormasterBuildStatus.php +++ b/src/applications/harbormaster/constants/HarbormasterBuildStatus.php @@ -118,4 +118,28 @@ final class HarbormasterBuildStatus extends Phobject { } } + public static function getWaitingStatusConstants() { + return array( + self::STATUS_INACTIVE, + self::STATUS_PENDING, + ); + } + + public static function getActiveStatusConstants() { + return array( + self::STATUS_BUILDING, + self::STATUS_PAUSED, + ); + } + + public static function getCompletedStatusConstants() { + return array( + self::STATUS_PASSED, + self::STATUS_FAILED, + self::STATUS_ABORTED, + self::STATUS_ERROR, + self::STATUS_DEADLOCKED, + ); + } + } diff --git a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php index 2999bcc6f4..0b07ca7150 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildSearchEngine.php @@ -55,6 +55,9 @@ final class HarbormasterBuildSearchEngine protected function getBuiltinQueryNames() { return array( 'all' => pht('All Builds'), + 'waiting' => pht('Waiting'), + 'active' => pht('Active'), + 'completed' => pht('Completed'), ); } @@ -65,6 +68,21 @@ final class HarbormasterBuildSearchEngine switch ($query_key) { case 'all': return $query; + case 'waiting': + return $query + ->setParameter( + 'statuses', + HarbormasterBuildStatus::getWaitingStatusConstants()); + case 'active': + return $query + ->setParameter( + 'statuses', + HarbormasterBuildStatus::getActiveStatusConstants()); + case 'completed': + return $query + ->setParameter( + 'statuses', + HarbormasterBuildStatus::getCompletedStatusConstants()); } return parent::buildSavedQueryFromBuiltin($query_key); diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuild.php b/src/applications/harbormaster/storage/build/HarbormasterBuild.php index 44846b9bc8..759f9b9fe0 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuild.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuild.php @@ -169,16 +169,9 @@ final class HarbormasterBuild extends HarbormasterDAO } public function isComplete() { - switch ($this->getBuildStatus()) { - case HarbormasterBuildStatus::STATUS_PASSED: - case HarbormasterBuildStatus::STATUS_FAILED: - case HarbormasterBuildStatus::STATUS_ABORTED: - case HarbormasterBuildStatus::STATUS_ERROR: - case HarbormasterBuildStatus::STATUS_PAUSED: - return true; - } - - return false; + return in_array( + $this->getBuildStatus(), + HarbormasterBuildStatus::getCompletedStatusConstants()); } public function isPaused() {