mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 11:30:55 +01:00
Add authorPHID to Dashboards
Summary: Adds an authorPHIDs, populates olds ones. Test Plan: Make a new Dashboard, see that I created it. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D17022
This commit is contained in:
parent
39b618039f
commit
59f3b5125d
5 changed files with 82 additions and 4 deletions
39
resources/sql/autopatches/20161210.dashboards.01.author.php
Normal file
39
resources/sql/autopatches/20161210.dashboards.01.author.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Set authorPHID on Dashboards
|
||||||
|
//
|
||||||
|
$table = new PhabricatorDashboard();
|
||||||
|
$conn_w = $table->establishConnection('w');
|
||||||
|
|
||||||
|
$txn_table = new PhabricatorDashboardTransaction();
|
||||||
|
$txn_conn = $table->establishConnection('r');
|
||||||
|
|
||||||
|
echo pht("Building Dashboard authorPHIDs...\n");
|
||||||
|
|
||||||
|
foreach (new LiskMigrationIterator($table) as $dashboard) {
|
||||||
|
|
||||||
|
if ($dashboard->getAuthorPHID()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$author_row = queryfx_one(
|
||||||
|
$txn_conn,
|
||||||
|
'SELECT authorPHID FROM %T WHERE objectPHID = %s ORDER BY id ASC LIMIT 1',
|
||||||
|
$txn_table->getTableName(),
|
||||||
|
$dashboard->getPHID());
|
||||||
|
|
||||||
|
if (!$author_row) {
|
||||||
|
$author_phid = id(new PhabricatorDashboardApplication())->getPHID();
|
||||||
|
} else {
|
||||||
|
$author_phid = $author_row['authorPHID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
queryfx(
|
||||||
|
$conn_w,
|
||||||
|
'UPDATE %T SET authorPHID = %s WHERE id = %d',
|
||||||
|
$table->getTableName(),
|
||||||
|
$author_phid,
|
||||||
|
$dashboard->getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
echo pht("Done\n");
|
|
@ -0,0 +1,2 @@
|
||||||
|
ALTER TABLE {$NAMESPACE}_dashboard.dashboard
|
||||||
|
ADD authorPHID VARBINARY(64) NOT NULL;
|
|
@ -6,6 +6,7 @@ final class PhabricatorDashboardQuery
|
||||||
private $ids;
|
private $ids;
|
||||||
private $phids;
|
private $phids;
|
||||||
private $statuses;
|
private $statuses;
|
||||||
|
private $authorPHIDs;
|
||||||
|
|
||||||
private $needPanels;
|
private $needPanels;
|
||||||
private $needProjects;
|
private $needProjects;
|
||||||
|
@ -25,6 +26,11 @@ final class PhabricatorDashboardQuery
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withAuthorPHIDs(array $authors) {
|
||||||
|
$this->authorPHIDs = $authors;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function needPanels($need_panels) {
|
public function needPanels($need_panels) {
|
||||||
$this->needPanels = $need_panels;
|
$this->needPanels = $need_panels;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -121,6 +127,13 @@ final class PhabricatorDashboardQuery
|
||||||
$this->statuses);
|
$this->statuses);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->authorPHIDs !== null) {
|
||||||
|
$where[] = qsprintf(
|
||||||
|
$conn,
|
||||||
|
'authorPHID IN (%Ls)',
|
||||||
|
$this->authorPHIDs);
|
||||||
|
}
|
||||||
|
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,10 @@ final class PhabricatorDashboardSearchEngine
|
||||||
|
|
||||||
protected function buildCustomSearchFields() {
|
protected function buildCustomSearchFields() {
|
||||||
return array(
|
return array(
|
||||||
|
id(new PhabricatorSearchDatasourceField())
|
||||||
|
->setLabel(pht('Authored By'))
|
||||||
|
->setKey('authorPHIDs')
|
||||||
|
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
|
||||||
id(new PhabricatorSearchCheckboxesField())
|
id(new PhabricatorSearchCheckboxesField())
|
||||||
->setKey('statuses')
|
->setKey('statuses')
|
||||||
->setLabel(pht('Status'))
|
->setLabel(pht('Status'))
|
||||||
|
@ -30,19 +34,32 @@ final class PhabricatorDashboardSearchEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getBuiltinQueryNames() {
|
protected function getBuiltinQueryNames() {
|
||||||
return array(
|
$names = array();
|
||||||
'open' => pht('Active Dashboards'),
|
|
||||||
'all' => pht('All Dashboards'),
|
if ($this->requireViewer()->isLoggedIn()) {
|
||||||
);
|
$names['authored'] = pht('Authored');
|
||||||
|
}
|
||||||
|
|
||||||
|
$names['open'] = pht('Active Dashboards');
|
||||||
|
$names['all'] = pht('All Dashboards');
|
||||||
|
|
||||||
|
return $names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildSavedQueryFromBuiltin($query_key) {
|
public function buildSavedQueryFromBuiltin($query_key) {
|
||||||
$query = $this->newSavedQuery();
|
$query = $this->newSavedQuery();
|
||||||
$query->setQueryKey($query_key);
|
$query->setQueryKey($query_key);
|
||||||
|
$viewer = $this->requireViewer();
|
||||||
|
|
||||||
switch ($query_key) {
|
switch ($query_key) {
|
||||||
case 'all':
|
case 'all':
|
||||||
return $query;
|
return $query;
|
||||||
|
case 'authored':
|
||||||
|
return $query->setParameter(
|
||||||
|
'authored',
|
||||||
|
array(
|
||||||
|
$viewer->getPHID(),
|
||||||
|
));
|
||||||
case 'open':
|
case 'open':
|
||||||
return $query->setParameter(
|
return $query->setParameter(
|
||||||
'statuses',
|
'statuses',
|
||||||
|
@ -61,6 +78,10 @@ final class PhabricatorDashboardSearchEngine
|
||||||
$query->withStatuses($map['statuses']);
|
$query->withStatuses($map['statuses']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($map['authorPHIDs']) {
|
||||||
|
$query->withAuthorPHIDs($map['authorPHIDs']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
||||||
PhabricatorProjectInterface {
|
PhabricatorProjectInterface {
|
||||||
|
|
||||||
protected $name;
|
protected $name;
|
||||||
|
protected $authorPHID;
|
||||||
protected $viewPolicy;
|
protected $viewPolicy;
|
||||||
protected $editPolicy;
|
protected $editPolicy;
|
||||||
protected $status;
|
protected $status;
|
||||||
|
@ -31,6 +32,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
||||||
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
->setViewPolicy(PhabricatorPolicies::POLICY_USER)
|
||||||
->setEditPolicy($actor->getPHID())
|
->setEditPolicy($actor->getPHID())
|
||||||
->setStatus(self::STATUS_ACTIVE)
|
->setStatus(self::STATUS_ACTIVE)
|
||||||
|
->setAuthorPHID($actor->getPHID())
|
||||||
->attachPanels(array())
|
->attachPanels(array())
|
||||||
->attachPanelPHIDs(array());
|
->attachPanelPHIDs(array());
|
||||||
}
|
}
|
||||||
|
@ -61,6 +63,7 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
|
||||||
self::CONFIG_COLUMN_SCHEMA => array(
|
self::CONFIG_COLUMN_SCHEMA => array(
|
||||||
'name' => 'text255',
|
'name' => 'text255',
|
||||||
'status' => 'text32',
|
'status' => 'text32',
|
||||||
|
'authorPHID' => 'phid',
|
||||||
),
|
),
|
||||||
) + parent::getConfiguration();
|
) + parent::getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue