@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.

Show import progress on repository main page

Summary: Fixes T9192.

Test Plan: {F1055042}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9192

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

+50 -41
+6 -1
src/applications/diffusion/controller/DiffusionRepositoryController.php
··· 223 223 if (!$repository->isTracked()) { 224 224 $header->setStatus('fa-ban', 'dark', pht('Inactive')); 225 225 } else if ($repository->isImporting()) { 226 - $header->setStatus('fa-clock-o', 'indigo', pht('Importing...')); 226 + $ratio = $repository->loadImportProgress(); 227 + $percentage = sprintf('%.2f%%', 100 * $ratio); 228 + $header->setStatus( 229 + 'fa-clock-o', 230 + 'indigo', 231 + pht('Importing (%s)...', $percentage)); 227 232 } else { 228 233 $header->setStatus('fa-check', 'bluegrey', pht('Active')); 229 234 }
+2 -39
src/applications/diffusion/controller/DiffusionRepositoryEditMainController.php
··· 1137 1137 } 1138 1138 1139 1139 if ($repository->isImporting()) { 1140 - $progress = queryfx_all( 1141 - $repository->establishConnection('r'), 1142 - 'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d 1143 - GROUP BY importStatus', 1144 - id(new PhabricatorRepositoryCommit())->getTableName(), 1145 - $repository->getID()); 1146 - 1147 - $done = 0; 1148 - $total = 0; 1149 - foreach ($progress as $row) { 1150 - $total += $row['N'] * 4; 1151 - $status = $row['importStatus']; 1152 - if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) { 1153 - $done += $row['N']; 1154 - } 1155 - if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) { 1156 - $done += $row['N']; 1157 - } 1158 - if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) { 1159 - $done += $row['N']; 1160 - } 1161 - if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) { 1162 - $done += $row['N']; 1163 - } 1164 - } 1165 - 1166 - if ($total) { 1167 - $percentage = 100 * ($done / $total); 1168 - } else { 1169 - $percentage = 0; 1170 - } 1171 - 1172 - // Cap this at "99.99%", because it's confusing to users when the actual 1173 - // fraction is "99.996%" and it rounds up to "100.00%". 1174 - if ($percentage > 99.99) { 1175 - $percentage = 99.99; 1176 - } 1177 - 1178 - $percentage = sprintf('%.2f%%', $percentage); 1140 + $ratio = $repository->loadImportProgress(); 1141 + $percentage = sprintf('%.2f%%', 100 * $ratio); 1179 1142 1180 1143 $view->addItem( 1181 1144 id(new PHUIStatusItemView())
+1 -1
src/applications/repository/query/PhabricatorRepositorySearchEngine.php
··· 205 205 $item->setDisabled(true); 206 206 $item->addIcon('disable-grey', pht('Inactive')); 207 207 } else if ($repository->isImporting()) { 208 - $item->addIcon('fa-clock-o violet', pht('Importing...')); 208 + $item->addIcon('fa-clock-o indigo', pht('Importing...')); 209 209 } 210 210 211 211 $list->addItem($item);
+41
src/applications/repository/storage/PhabricatorRepository.php
··· 867 867 return (bool)$this->getDetail('importing', false); 868 868 } 869 869 870 + public function loadImportProgress() { 871 + $progress = queryfx_all( 872 + $this->establishConnection('r'), 873 + 'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d 874 + GROUP BY importStatus', 875 + id(new PhabricatorRepositoryCommit())->getTableName(), 876 + $this->getID()); 877 + 878 + $done = 0; 879 + $total = 0; 880 + foreach ($progress as $row) { 881 + $total += $row['N'] * 4; 882 + $status = $row['importStatus']; 883 + if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) { 884 + $done += $row['N']; 885 + } 886 + if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) { 887 + $done += $row['N']; 888 + } 889 + if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) { 890 + $done += $row['N']; 891 + } 892 + if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) { 893 + $done += $row['N']; 894 + } 895 + } 896 + 897 + if ($total) { 898 + $ratio = ($done / $total); 899 + } else { 900 + $ratio = 0; 901 + } 902 + 903 + // Cap this at "99.99%", because it's confusing to users when the actual 904 + // fraction is "99.996%" and it rounds up to "100.00%". 905 + if ($ratio > 0.9999) { 906 + $ratio = 0.9999; 907 + } 908 + 909 + return $ratio; 910 + } 870 911 871 912 /** 872 913 * Should this repository publish feed, notifications, audits, and email?