Differential D16848 Diff 40576 src/infrastructure/storage/management/workflow/PhabricatorStorageManagementStatusWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementStatusWorkflow.php
| Show All 9 Lines | $this | ||||
| ->setSynopsis(pht('Show patch application status.')); | ->setSynopsis(pht('Show patch application status.')); | ||||
| } | } | ||||
| protected function isReadOnlyWorkflow() { | protected function isReadOnlyWorkflow() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function didExecute(PhutilArgumentParser $args) { | public function didExecute(PhutilArgumentParser $args) { | ||||
| $api = $this->getAPI(); | foreach ($this->getAPIs() as $api) { | ||||
| $patches = $this->getPatches(); | $patches = $this->getPatches(); | ||||
| $applied = $api->getAppliedPatches(); | $applied = $api->getAppliedPatches(); | ||||
| if ($applied === null) { | if ($applied === null) { | ||||
| echo phutil_console_format( | echo phutil_console_format( | ||||
| "**%s**: %s\n", | "**%s**: %s\n", | ||||
| pht('Database Not Initialized'), | pht('Database Not Initialized'), | ||||
| pht('Run **%s** to initialize.', './bin/storage upgrade')); | pht('Run **%s** to initialize.', './bin/storage upgrade')); | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| $ref = $api->getRef(); | |||||
| $table = id(new PhutilConsoleTable()) | $table = id(new PhutilConsoleTable()) | ||||
| ->setShowHeader(false) | ->setShowHeader(false) | ||||
| ->addColumn('id', array('title' => pht('ID'))) | ->addColumn('id', array('title' => pht('ID'))) | ||||
| ->addColumn('host', array('title' => pht('Host'))) | |||||
| ->addColumn('status', array('title' => pht('Status'))) | ->addColumn('status', array('title' => pht('Status'))) | ||||
| ->addColumn('duration', array('title' => pht('Duration'))) | ->addColumn('duration', array('title' => pht('Duration'))) | ||||
| ->addColumn('type', array('title' => pht('Type'))) | ->addColumn('type', array('title' => pht('Type'))) | ||||
| ->addColumn('name', array('title' => pht('Name'))); | ->addColumn('name', array('title' => pht('Name'))); | ||||
| $durations = $api->getPatchDurations(); | $durations = $api->getPatchDurations(); | ||||
| foreach ($patches as $patch) { | foreach ($patches as $patch) { | ||||
| $duration = idx($durations, $patch->getFullKey()); | $duration = idx($durations, $patch->getFullKey()); | ||||
| if ($duration === null) { | if ($duration === null) { | ||||
| $duration = '-'; | $duration = '-'; | ||||
| } else { | } else { | ||||
| $duration = pht('%s us', new PhutilNumber($duration)); | $duration = pht('%s us', new PhutilNumber($duration)); | ||||
| } | } | ||||
| $table->addRow(array( | $table->addRow(array( | ||||
| 'id' => $patch->getFullKey(), | 'id' => $patch->getFullKey(), | ||||
| 'host' => $ref->getRefKey(), | |||||
| 'status' => in_array($patch->getFullKey(), $applied) | 'status' => in_array($patch->getFullKey(), $applied) | ||||
| ? pht('Applied') | ? pht('Applied') | ||||
| : pht('Not Applied'), | : pht('Not Applied'), | ||||
| 'duration' => $duration, | 'duration' => $duration, | ||||
| 'type' => $patch->getType(), | 'type' => $patch->getType(), | ||||
| 'name' => $patch->getName(), | 'name' => $patch->getName(), | ||||
| )); | )); | ||||
| } | } | ||||
| $table->draw(); | $table->draw(); | ||||
| } | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||