1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Display auditors in audit commit list

Summary: Users wonder who is actually doing all these audits.

Test Plan:
/owners/package/1/
/audit/view/packagecommits/?phid=PHID-OPKG-1

Reviewers: epriestley

Reviewed By: epriestley

CC: jungejason, aran, Korvin

Differential Revision: https://secure.phabricator.com/D3597
This commit is contained in:
vrana 2012-10-02 16:44:29 -07:00
parent 087c328f89
commit b585146532
5 changed files with 57 additions and 0 deletions

View file

@ -412,6 +412,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$query = new PhabricatorAuditCommitQuery();
$query->needCommitData(true);
$query->needAudits(true);
$use_pager = ($this->filter != 'active');

View file

@ -27,6 +27,7 @@ final class PhabricatorAuditCommitQuery {
private $identifiers = array();
private $needCommitData;
private $needAudits;
private $status = 'status-any';
const STATUS_ANY = 'status-any';
@ -62,6 +63,11 @@ final class PhabricatorAuditCommitQuery {
return $this;
}
public function needAudits($need) {
$this->needAudits = $need;
return $this;
}
public function setOffset($offset) {
$this->offset = $offset;
return $this;
@ -107,6 +113,16 @@ final class PhabricatorAuditCommitQuery {
}
}
if ($this->needAudits && $commits) {
$audits = id(new PhabricatorAuditComment())->loadAllWhere(
'targetPHID in (%Ls)',
mpull($commits, 'getPHID'));
$audits = mgroup($audits, 'getTargetPHID');
foreach ($commits as $commit) {
$commit->attachAudits(idx($audits, $commit->getPHID(), array()));
}
}
return $commits;
}

View file

@ -57,6 +57,11 @@ final class PhabricatorAuditCommitListView extends AphrontView {
$phids[$commit->getAuthorPHID()] = true;
}
$phids[$commit->getPHID()] = true;
if ($commit->getAudits()) {
foreach ($commit->getAudits() as $audit) {
$phids[$audit->getActorPHID()] = true;
}
}
}
return array_keys($phids);
}
@ -77,12 +82,20 @@ final class PhabricatorAuditCommitListView extends AphrontView {
if ($commit->getAuthorPHID()) {
$author_name = $this->getHandle($commit->getAuthorPHID())->renderLink();
}
$auditors = array();
if ($commit->getAudits()) {
foreach ($commit->getAudits() as $audit) {
$actor_phid = $audit->getActorPHID();
$auditors[$actor_phid] = $this->getHandle($actor_phid)->renderLink();
}
}
$rows[] = array(
$commit_name,
$author_name,
phutil_escape_html($commit->getCommitData()->getSummary()),
PhabricatorAuditCommitStatusConstants::getStatusName(
$commit->getAuditStatus()),
implode(', ', $auditors),
phabricator_datetime($commit->getEpoch(), $this->user),
);
}
@ -94,6 +107,7 @@ final class PhabricatorAuditCommitListView extends AphrontView {
'Author',
'Summary',
'Audit Status',
'Auditors',
'Date',
));
$table->setColumnClasses(
@ -103,8 +117,21 @@ final class PhabricatorAuditCommitListView extends AphrontView {
'wide',
'',
'',
'',
));
if ($this->commits && reset($this->commits)->getAudits() === null) {
$table->setColumnVisibility(
array(
true,
true,
true,
true,
false,
true,
));
}
if ($this->noDataString) {
$table->setNoDataString($this->noDataString);
}

View file

@ -164,6 +164,7 @@ final class PhabricatorOwnersDetailController
->withPackagePHIDs(array($package->getPHID()))
->withStatus(PhabricatorAuditCommitQuery::STATUS_OPEN)
->needCommitData(true)
->needAudits(true)
->setLimit(10);
$attention_commits = $attention_query->execute();
if ($attention_commits) {
@ -187,6 +188,7 @@ final class PhabricatorOwnersDetailController
$all_query = id(new PhabricatorAuditCommitQuery())
->withPackagePHIDs(array($package->getPHID()))
->needCommitData(true)
->needAudits(true)
->setLimit(100);
$all_commits = $all_query->execute();

View file

@ -27,6 +27,7 @@ final class PhabricatorRepositoryCommit extends PhabricatorRepositoryDAO {
protected $auditStatus = PhabricatorAuditCommitStatusConstants::NONE;
private $commitData;
private $audits;
private $isUnparsed;
public function setIsUnparsed($is_unparsed) {
@ -71,6 +72,16 @@ final class PhabricatorRepositoryCommit extends PhabricatorRepositoryDAO {
return $this->commitData;
}
public function attachAudits(array $audits) {
assert_instances_of($audits, 'PhabricatorAuditComment');
$this->audits = $audits;
return $this;
}
public function getAudits() {
return $this->audits;
}
public function save() {
if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20);