1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +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 = new PhabricatorAuditCommitQuery();
$query->needCommitData(true); $query->needCommitData(true);
$query->needAudits(true);
$use_pager = ($this->filter != 'active'); $use_pager = ($this->filter != 'active');

View file

@ -27,6 +27,7 @@ final class PhabricatorAuditCommitQuery {
private $identifiers = array(); private $identifiers = array();
private $needCommitData; private $needCommitData;
private $needAudits;
private $status = 'status-any'; private $status = 'status-any';
const STATUS_ANY = 'status-any'; const STATUS_ANY = 'status-any';
@ -62,6 +63,11 @@ final class PhabricatorAuditCommitQuery {
return $this; return $this;
} }
public function needAudits($need) {
$this->needAudits = $need;
return $this;
}
public function setOffset($offset) { public function setOffset($offset) {
$this->offset = $offset; $this->offset = $offset;
return $this; 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; return $commits;
} }

View file

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

View file

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

View file

@ -27,6 +27,7 @@ final class PhabricatorRepositoryCommit extends PhabricatorRepositoryDAO {
protected $auditStatus = PhabricatorAuditCommitStatusConstants::NONE; protected $auditStatus = PhabricatorAuditCommitStatusConstants::NONE;
private $commitData; private $commitData;
private $audits;
private $isUnparsed; private $isUnparsed;
public function setIsUnparsed($is_unparsed) { public function setIsUnparsed($is_unparsed) {
@ -71,6 +72,16 @@ final class PhabricatorRepositoryCommit extends PhabricatorRepositoryDAO {
return $this->commitData; 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() { public function save() {
if (!$this->mailKey) { if (!$this->mailKey) {
$this->mailKey = Filesystem::readRandomCharacters(20); $this->mailKey = Filesystem::readRandomCharacters(20);