diff --git a/resources/sql/autopatches/20140807.harbormastertargettime.sql b/resources/sql/autopatches/20140807.harbormastertargettime.sql new file mode 100644 --- /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 --- a/src/applications/harbormaster/controller/HarbormasterBuildViewController.php +++ b/src/applications/harbormaster/controller/HarbormasterBuildViewController.php @@ -94,6 +94,28 @@ $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 @@ ->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 --- a/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php +++ b/src/applications/harbormaster/storage/build/HarbormasterBuildTarget.php @@ -10,6 +10,8 @@ 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 --- a/src/applications/harbormaster/worker/HarbormasterTargetWorker.php +++ b/src/applications/harbormaster/worker/HarbormasterTargetWorker.php @@ -35,6 +35,8 @@ $build = $target->getBuild(); $viewer = $this->getViewer(); + $target->setDateStarted(time()); + try { $status_pending = HarbormasterBuildTarget::STATUS_PENDING; if ($target->getTargetStatus() == $status_pending) { @@ -51,6 +53,11 @@ } $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 @@ } 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 @@ } $target->setTargetStatus(HarbormasterBuildTarget::STATUS_FAILED); + $target->setDateCompleted(time()); $target->save(); }