@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Use PhutilConsoleTable in `./bin/storage probe`

Summary: Fixes T8477. Use `PhutilConsoleTable` to render the output from `./bin/storage probe`.

Test Plan: Ran `./bin/storage probe` and saw tabulated output.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Maniphest Tasks: T8477

Differential Revision: https://secure.phabricator.com/D13339

+41 -18
+41 -18
src/infrastructure/storage/management/workflow/PhabricatorStorageManagementProbeWorkflow.php
··· 45 45 } 46 46 } 47 47 48 - $console->writeOut("%s\n", pht('APPROXIMATE TABLE SIZES')); 49 48 asort($totals); 49 + 50 + $table = id(new PhutilConsoleTable()) 51 + ->setShowHeader(false) 52 + ->setPadding(2) 53 + ->addColumn('name', array('title' => pht('Database / Table'))) 54 + ->addColumn('size', array('title' => pht('Size'))) 55 + ->addColumn('percentage', array('title' => pht('Percentage'))); 56 + 50 57 foreach ($totals as $db => $size) { 51 - $database_size = $this->formatSize($totals[$db], $overall); 52 - $console->writeOut( 53 - "**%s**\n", 54 - sprintf('%-32.32s %18s', $db, $database_size)); 58 + list($database_size, $database_percentage) = $this->formatSize( 59 + $totals[$db], 60 + $overall); 61 + 62 + $table->addRow(array( 63 + 'name' => phutil_console_format('**%s**', $db), 64 + 'size' => phutil_console_format('**%s**', $database_size), 65 + 'percentage' => phutil_console_format('**%s**', $database_percentage), 66 + )); 55 67 $data[$db] = isort($data[$db], '_totalSize'); 56 - foreach ($data[$db] as $table => $info) { 57 - $table_size = $this->formatSize($info['_totalSize'], $overall); 58 - $console->writeOut( 59 - "%s\n", 60 - sprintf(' %-28.28s %18s', $table, $table_size)); 68 + foreach ($data[$db] as $table_name => $info) { 69 + list($table_size, $table_percentage) = $this->formatSize( 70 + $info['_totalSize'], 71 + $overall); 72 + 73 + $table->addRow(array( 74 + 'name' => ' '.$table_name, 75 + 'size' => $table_size, 76 + 'percentage' => $table_percentage, 77 + )); 61 78 } 62 79 } 63 - $overall_size = $this->formatSize($overall, $overall); 64 - $console->writeOut( 65 - "**%s**\n", 66 - sprintf('%-32.32s %18s', pht('TOTAL'), $overall_size)); 80 + 81 + list($overall_size, $overall_percentage) = $this->formatSize( 82 + $overall, 83 + $overall); 84 + $table->addRow(array( 85 + 'name' => phutil_console_format('**%s**', pht('TOTAL')), 86 + 'size' => phutil_console_format('**%s**', $overall_size), 87 + 'percentage' => phutil_console_format('**%s**', $overall_percentage), 88 + )); 67 89 90 + $table->draw(); 68 91 return 0; 69 92 } 70 93 71 94 private function formatSize($n, $o) { 72 - return sprintf( 73 - '%8.8s MB %5.5s%%', 74 - number_format($n / (1024 * 1024), 1), 75 - sprintf('%3.1f', 100 * ($n / $o))); 95 + return array( 96 + sprintf('%8.8s MB', number_format($n / (1024 * 1024), 1)), 97 + sprintf('%3.1f%%', 100 * ($n / $o)), 98 + ); 76 99 } 77 100 78 101 }