mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
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
This commit is contained in:
parent
d0cdf1efdb
commit
94d79c11a9
4 changed files with 50 additions and 41 deletions
|
@ -223,7 +223,12 @@ final class DiffusionRepositoryController extends DiffusionController {
|
||||||
if (!$repository->isTracked()) {
|
if (!$repository->isTracked()) {
|
||||||
$header->setStatus('fa-ban', 'dark', pht('Inactive'));
|
$header->setStatus('fa-ban', 'dark', pht('Inactive'));
|
||||||
} else if ($repository->isImporting()) {
|
} else if ($repository->isImporting()) {
|
||||||
$header->setStatus('fa-clock-o', 'indigo', pht('Importing...'));
|
$ratio = $repository->loadImportProgress();
|
||||||
|
$percentage = sprintf('%.2f%%', 100 * $ratio);
|
||||||
|
$header->setStatus(
|
||||||
|
'fa-clock-o',
|
||||||
|
'indigo',
|
||||||
|
pht('Importing (%s)...', $percentage));
|
||||||
} else {
|
} else {
|
||||||
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
|
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,45 +1137,8 @@ final class DiffusionRepositoryEditMainController
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($repository->isImporting()) {
|
if ($repository->isImporting()) {
|
||||||
$progress = queryfx_all(
|
$ratio = $repository->loadImportProgress();
|
||||||
$repository->establishConnection('r'),
|
$percentage = sprintf('%.2f%%', 100 * $ratio);
|
||||||
'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d
|
|
||||||
GROUP BY importStatus',
|
|
||||||
id(new PhabricatorRepositoryCommit())->getTableName(),
|
|
||||||
$repository->getID());
|
|
||||||
|
|
||||||
$done = 0;
|
|
||||||
$total = 0;
|
|
||||||
foreach ($progress as $row) {
|
|
||||||
$total += $row['N'] * 4;
|
|
||||||
$status = $row['importStatus'];
|
|
||||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) {
|
|
||||||
$done += $row['N'];
|
|
||||||
}
|
|
||||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) {
|
|
||||||
$done += $row['N'];
|
|
||||||
}
|
|
||||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) {
|
|
||||||
$done += $row['N'];
|
|
||||||
}
|
|
||||||
if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) {
|
|
||||||
$done += $row['N'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($total) {
|
|
||||||
$percentage = 100 * ($done / $total);
|
|
||||||
} else {
|
|
||||||
$percentage = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cap this at "99.99%", because it's confusing to users when the actual
|
|
||||||
// fraction is "99.996%" and it rounds up to "100.00%".
|
|
||||||
if ($percentage > 99.99) {
|
|
||||||
$percentage = 99.99;
|
|
||||||
}
|
|
||||||
|
|
||||||
$percentage = sprintf('%.2f%%', $percentage);
|
|
||||||
|
|
||||||
$view->addItem(
|
$view->addItem(
|
||||||
id(new PHUIStatusItemView())
|
id(new PHUIStatusItemView())
|
||||||
|
|
|
@ -205,7 +205,7 @@ final class PhabricatorRepositorySearchEngine
|
||||||
$item->setDisabled(true);
|
$item->setDisabled(true);
|
||||||
$item->addIcon('disable-grey', pht('Inactive'));
|
$item->addIcon('disable-grey', pht('Inactive'));
|
||||||
} else if ($repository->isImporting()) {
|
} else if ($repository->isImporting()) {
|
||||||
$item->addIcon('fa-clock-o violet', pht('Importing...'));
|
$item->addIcon('fa-clock-o indigo', pht('Importing...'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$list->addItem($item);
|
$list->addItem($item);
|
||||||
|
|
|
@ -867,6 +867,47 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
return (bool)$this->getDetail('importing', false);
|
return (bool)$this->getDetail('importing', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadImportProgress() {
|
||||||
|
$progress = queryfx_all(
|
||||||
|
$this->establishConnection('r'),
|
||||||
|
'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d
|
||||||
|
GROUP BY importStatus',
|
||||||
|
id(new PhabricatorRepositoryCommit())->getTableName(),
|
||||||
|
$this->getID());
|
||||||
|
|
||||||
|
$done = 0;
|
||||||
|
$total = 0;
|
||||||
|
foreach ($progress as $row) {
|
||||||
|
$total += $row['N'] * 4;
|
||||||
|
$status = $row['importStatus'];
|
||||||
|
if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) {
|
||||||
|
$done += $row['N'];
|
||||||
|
}
|
||||||
|
if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) {
|
||||||
|
$done += $row['N'];
|
||||||
|
}
|
||||||
|
if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) {
|
||||||
|
$done += $row['N'];
|
||||||
|
}
|
||||||
|
if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) {
|
||||||
|
$done += $row['N'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($total) {
|
||||||
|
$ratio = ($done / $total);
|
||||||
|
} else {
|
||||||
|
$ratio = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap this at "99.99%", because it's confusing to users when the actual
|
||||||
|
// fraction is "99.996%" and it rounds up to "100.00%".
|
||||||
|
if ($ratio > 0.9999) {
|
||||||
|
$ratio = 0.9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ratio;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this repository publish feed, notifications, audits, and email?
|
* Should this repository publish feed, notifications, audits, and email?
|
||||||
|
|
Loading…
Reference in a new issue