Changeset View
Changeset View
Standalone View
Standalone View
src/applications/maniphest/controller/ManiphestReportController.php
Show First 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setNavigation($nav); | ->setNavigation($nav); | ||||
} | } | ||||
/** | |||||
* @return array<AphrontListFilterView, PHUIObjectBoxView> | |||||
*/ | |||||
public function renderBurn() { | public function renderBurn() { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$handle = null; | $handle = null; | ||||
$project_phid = $request->getStr('project'); | $project_phid = $request->getStr('project'); | ||||
if ($project_phid) { | if ($project_phid) { | ||||
$phids = array($project_phid); | $phids = array($project_phid); | ||||
$handles = $this->loadViewerHandles($phids); | $handles = $this->loadViewerHandles($phids); | ||||
$handle = $handles[$project_phid]; | $handle = $handles[$project_phid]; | ||||
} | } | ||||
$table = new ManiphestTransaction(); | $xtable = new ManiphestTransaction(); | ||||
$conn = $table->establishConnection('r'); | $conn = $xtable->establishConnection('r'); | ||||
// Get legacy data: Querying the task transaction table is only needed for | |||||
// code before rPd321cc81 got merged on 2017-11-22. | |||||
if ($project_phid) { | if ($project_phid) { | ||||
$joins = qsprintf( | $legacy_joins = qsprintf( | ||||
$conn, | $conn, | ||||
'JOIN %T t ON x.objectPHID = t.phid | 'JOIN %T t ON x.objectPHID = t.phid | ||||
JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', | JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', | ||||
id(new ManiphestTask())->getTableName(), | id(new ManiphestTask())->getTableName(), | ||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | PhabricatorEdgeConfig::TABLE_NAME_EDGE, | ||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | ||||
$project_phid); | $project_phid); | ||||
$create_joins = qsprintf( | |||||
$conn, | |||||
'JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', | |||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | |||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | |||||
$project_phid); | |||||
} else { | } else { | ||||
$joins = qsprintf($conn, ''); | $legacy_joins = qsprintf($conn, ''); | ||||
$create_joins = qsprintf($conn, ''); | |||||
} | } | ||||
$data = queryfx_all( | $legacy_data = queryfx_all( | ||||
$conn, | $conn, | ||||
'SELECT x.transactionType, x.oldValue, x.newValue, x.dateCreated | 'SELECT x.transactionType, x.oldValue, x.newValue, x.dateCreated | ||||
FROM %T x %Q | FROM %T x %Q | ||||
WHERE transactionType IN (%Ls) | WHERE transactionType IN (%Ls) | ||||
ORDER BY x.dateCreated ASC', | ORDER BY x.dateCreated ASC', | ||||
$table->getTableName(), | $xtable->getTableName(), | ||||
$joins, | $legacy_joins, | ||||
array( | array( | ||||
ManiphestTaskStatusTransaction::TRANSACTIONTYPE, | ManiphestTaskStatusTransaction::TRANSACTIONTYPE, | ||||
ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE, | ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE, | ||||
)); | )); | ||||
// See PHI273. After the move to EditEngine, we no longer create a | |||||
// "status" transaction if a task is created directly into the default | |||||
// status. This likely impacted API/email tasks after 2016 and all other | |||||
// tasks after late 2017. Until Facts can fix this properly, use the | |||||
// task creation dates to generate synthetic transactions which look like | |||||
// the older transactions that this page expects. | |||||
$default_status = ManiphestTaskStatus::getDefaultStatus(); | |||||
$duplicate_status = ManiphestTaskStatus::getDuplicateStatus(); | |||||
// Build synthetic transactions which take status from `null` to the | |||||
// default value. | |||||
$create_rows = queryfx_all( | |||||
$conn, | |||||
'SELECT t.dateCreated FROM %T t %Q', | |||||
id(new ManiphestTask())->getTableName(), | |||||
$create_joins); | |||||
foreach ($create_rows as $key => $create_row) { | |||||
$create_rows[$key] = array( | |||||
'transactionType' => 'status', | |||||
'oldValue' => null, | |||||
'newValue' => $default_status, | |||||
'dateCreated' => $create_row['dateCreated'], | |||||
); | |||||
} | |||||
// Remove any actual legacy status transactions which take status from | // Remove any actual legacy status transactions which take status from | ||||
// `null` to any open status. | // `null` to any open status. | ||||
foreach ($data as $key => $row) { | foreach ($legacy_data as $key => $row) { | ||||
if ($row['transactionType'] != 'status') { | if ($row['transactionType'] != 'status') { | ||||
continue; | continue; | ||||
} | } | ||||
$oldv = trim($row['oldValue'], '"'); | $oldv = trim($row['oldValue'], '"'); | ||||
$newv = trim($row['newValue'], '"'); | $newv = trim($row['newValue'], '"'); | ||||
// If this is a status change, preserve it. | // If this is a status change, preserve it. | ||||
if ($oldv != 'null') { | if ($oldv != 'null') { | ||||
continue; | continue; | ||||
} | } | ||||
// If this task was created directly into a closed status, preserve | // If this task was created directly into a closed status, preserve | ||||
// the transaction. | // the transaction. | ||||
if (!ManiphestTaskStatus::isOpenStatus($newv)) { | if (!ManiphestTaskStatus::isOpenStatus($newv)) { | ||||
continue; | continue; | ||||
} | } | ||||
// If this is a legacy "create" transaction, discard it in favor of the | // If this is a legacy "create" transaction, discard it in favor of the | ||||
// synthetic one. | // synthetic transaction to be created below. | ||||
unset($data[$key]); | unset($legacy_data[$key]); | ||||
} | } | ||||
// Merge the synthetic rows into the real transactions. | // Since rPd321cc81, after the move to EditEngine, we no longer create a | ||||
$data = array_merge($create_rows, $data); | // "status" transaction if a task is created directly into the default | ||||
// status. This likely impacted API/email tasks after 2016 and all other | |||||
// tasks after deploying the Phorge codebase from 2017-11-22. | |||||
valerio.bozzolan: Maybe this ↑ should say "Phabricator", since Phorge was not existing in 2017
(sorry for my… | |||||
Done Inline ActionsI edited the Wikipedia article (so it must be true!) to state that the first ancient relics of Phorge ever found were determined via C14 to be from the 18th century AD. More relevant though: How can I move this very patchset into a branch on its own, sigh? aklapper: I edited the Wikipedia article (so it must be true!) to state that the first ancient relics of… | |||||
Not Done Inline ActionsUhm. Try running arc patch D25828 then arc diff again lol. I don't know :D Good luck valerio.bozzolan: Uhm. Try running `arc patch D25828` then `arc diff` again lol. I don't know :D Good luck | |||||
// Until Facts can fix this properly, use the task creation dates to | |||||
// generate synthetic transactions which look like the older transactions | |||||
// that this page expects. | |||||
$default_status = ManiphestTaskStatus::getDefaultStatus(); | |||||
$duplicate_status = ManiphestTaskStatus::getDuplicateStatus(); | |||||
if ($project_phid) { | |||||
$synth_joins = qsprintf( | |||||
$conn, | |||||
'JOIN %T p ON p.src = t.phid AND p.type = %d AND p.dst = %s', | |||||
PhabricatorEdgeConfig::TABLE_NAME_EDGE, | |||||
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, | |||||
$project_phid); | |||||
} else { | |||||
$synth_joins = qsprintf($conn, ''); | |||||
} | |||||
// Build synthetic transactions which take status from `null` to the | |||||
// default value. | |||||
$synth_data = queryfx_all( | |||||
$conn, | |||||
'SELECT t.dateCreated FROM %T t %Q', | |||||
id(new ManiphestTask())->getTableName(), | |||||
$synth_joins); | |||||
foreach ($synth_data as $key => $synth_row) { | |||||
$synth_data[$key] = array( | |||||
'transactionType' => 'status', | |||||
'oldValue' => null, | |||||
'newValue' => $default_status, | |||||
'dateCreated' => $synth_row['dateCreated'], | |||||
); | |||||
} | |||||
// Merge the synthetic transactions into the legacy transactions. | |||||
$data = array_merge($synth_data, $legacy_data); | |||||
$data = array_values($data); | $data = array_values($data); | ||||
$data = isort($data, 'dateCreated'); | $data = isort($data, 'dateCreated'); | ||||
$stats = array(); | $stats = array(); | ||||
$day_buckets = array(); | $day_buckets = array(); | ||||
$open_tasks = array(); | $open_tasks = array(); | ||||
▲ Show 20 Lines • Show All 222 Lines • ▼ Show 20 Lines | $chart_view = id(new PhabricatorDashboardPanelRenderingEngine()) | ||||
->setViewer($viewer) | ->setViewer($viewer) | ||||
->setPanel($panel) | ->setPanel($panel) | ||||
->setParentPanelPHIDs(array()) | ->setParentPanelPHIDs(array()) | ||||
->renderPanel(); | ->renderPanel(); | ||||
return array($filter, $chart_view); | return array($filter, $chart_view); | ||||
} | } | ||||
/** | |||||
* @param array $tokens | |||||
* @param bool $has_window | |||||
* @return AphrontListFilterView | |||||
*/ | |||||
private function renderReportFilters(array $tokens, $has_window) { | private function renderReportFilters(array $tokens, $has_window) { | ||||
$request = $this->getRequest(); | $request = $this->getRequest(); | ||||
$viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
$form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->appendControl( | ->appendControl( | ||||
id(new AphrontFormTokenizerControl()) | id(new AphrontFormTokenizerControl()) | ||||
▲ Show 20 Lines • Show All 484 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Maybe this ↑ should say "Phabricator", since Phorge was not existing in 2017
(sorry for my unuseful comment lol)