diff --git a/resources/sql/autopatches/20140807.harbormastertargettime.sql b/resources/sql/autopatches/20140807.harbormastertargettime.sql new file mode 100644 index 0000000000..88b8c175f9 --- /dev/null +++ b/resources/sql/autopatches/20140807.harbormastertargettime.sql @@ -0,0 +1,5 @@ +ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget + ADD dateStarted INT UNSIGNED NULL; + +ALTER TABLE {$NAMESPACE}_harbormaster.harbormaster_buildtarget + ADD dateCompleted INT UNSIGNED NULL; diff --git a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php index 10f436efad..63c5685a45 100644 --- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php @@ -94,6 +94,28 @@ final class HarbormasterBuildViewController $status_view->addItem($item); $properties->addProperty(pht('Name'), $build_target->getName()); + + if ($build_target->getDateStarted() !== null) { + $properties->addProperty( + pht('Started'), + phabricator_datetime($build_target->getDateStarted(), $viewer)); + if ($build_target->isComplete()) { + $properties->addProperty( + pht('Completed'), + phabricator_datetime($build_target->getDateCompleted(), $viewer)); + $properties->addProperty( + pht('Duration'), + phutil_format_relative_time_detailed( + $build_target->getDateCompleted() - + $build_target->getDateStarted())); + } else { + $properties->addProperty( + pht('Elapsed'), + phutil_format_relative_time_detailed( + time() - $build_target->getDateStarted())); + } + } + $properties->addProperty(pht('Status'), $status_view); $target_box->addPropertyList($properties, pht('Overview')); @@ -192,7 +214,10 @@ final class HarbormasterBuildViewController ->setFlush(true); foreach ($artifacts as $artifact) { - $list->addItem($artifact->getObjectItemView($viewer)); + $item = $artifact->getObjectItemView($viewer); + if ($item !== null) { + $list->addItem($item); + } } return $list; diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php index 3dc15f3843..e07d219f88 100644 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php @@ -10,6 +10,8 @@ final class HarbormasterBuildTarget extends HarbormasterDAO protected $details; protected $variables; protected $targetStatus; + protected $dateStarted; + protected $dateCompleted; const STATUS_PENDING = 'target/pending'; const STATUS_BUILDING = 'target/building'; diff --git a/src/applications/harbormaster/worker/HarbormasterTargetWorker.php b/src/applications/harbormaster/worker/HarbormasterTargetWorker.php index da61cfe82e..f76108f934 100644 --- a/src/applications/harbormaster/worker/HarbormasterTargetWorker.php +++ b/src/applications/harbormaster/worker/HarbormasterTargetWorker.php @@ -35,6 +35,8 @@ final class HarbormasterTargetWorker extends HarbormasterWorker { $build = $target->getBuild(); $viewer = $this->getViewer(); + $target->setDateStarted(time()); + try { $status_pending = HarbormasterBuildTarget::STATUS_PENDING; if ($target->getTargetStatus() == $status_pending) { @@ -51,6 +53,11 @@ final class HarbormasterTargetWorker extends HarbormasterWorker { } $target->setTargetStatus($next_status); + + if ($target->isComplete()) { + $target->setDateCompleted(time()); + } + $target->save(); } catch (PhabricatorWorkerYieldException $ex) { // If the target wants to yield, let that escape without further @@ -59,6 +66,7 @@ final class HarbormasterTargetWorker extends HarbormasterWorker { } catch (HarbormasterBuildFailureException $ex) { // A build step wants to fail explicitly. $target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED); + $target->setDateCompleted(time()); $target->save(); } catch (Exception $ex) { phlog($ex); @@ -73,6 +81,7 @@ final class HarbormasterTargetWorker extends HarbormasterWorker { } $target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED); + $target->setDateCompleted(time()); $target->save(); }