Move Project list to use ManiphestTaskQuery

Summary: We decided to move away from driving everything through the search
engine since it doesn't scale terribly well, so use ManiphestTaskQuery instead.
Also link the open count and tweak some display stuff.
Test Plan: Looked at project list, clicked open tasks link
Reviewed By: tuomaspelkonen
Reviewers: cadamo, aran, jungejason, tuomaspelkonen
CC: aran, tuomaspelkonen
Differential Revision: 608
This commit is contained in:
epriestley
2011-07-07 13:50:56 -07:00
parent 62532ef26d
commit cef7664d47
7 changed files with 49 additions and 105 deletions

View File

@@ -43,37 +43,39 @@ class PhabricatorProjectListController
$handles = id(new PhabricatorObjectHandleData($author_phids))
->loadHandles();
$project_phids = mpull($projects, 'getPHID');
$query = id(new ManiphestTaskQuery())
->withProjects($project_phids)
->withAnyProject(true)
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
->setLimit(PHP_INT_MAX);
$tasks = $query->execute();
$groups = array();
foreach ($tasks as $task) {
foreach ($task->getProjectPHIDs() as $phid) {
$groups[$phid][] = $task;
}
}
$rows = array();
foreach ($projects as $project) {
$profile = $profiles[$project->getPHID()];
$affiliations = $affil_groups[$project->getPHID()];
$phid = $project->getPHID();
$documents = new PhabricatorProjectTransactionSearch($project->getPHID());
// search all open documents by default
$documents->setSearchOptions();
$documents = $documents->executeSearch();
$profile = $profiles[$phid];
$affiliations = $affil_groups[$phid];
$documents_types = igroup($documents, 'documentType');
$tasks = idx(
$documents_types,
PhabricatorPHIDConstants::PHID_TYPE_TASK);
$tasks_amount = count($tasks);
// TODO: set up a relationship between the project and the arcanist's
// project, to be able get the revisions.
$revisions = idx(
$documents_types,
PhabricatorPHIDConstants::PHID_TYPE_DREV);
$revisions_amount = count($revisions);
$group = idx($groups, $phid, array());
$task_count = count($group);
$population = count($affiliations);
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());
$blurb = nonempty(
$profile->getBlurb(),
'Oops!, nothing is known about this elusive project.');
$blurb = $profile->getBlurb();
$blurb = phutil_utf8_shorten($blurb, $columns = 100);
$rows[] = array(
@@ -82,8 +84,12 @@ class PhabricatorProjectListController
$handles[$project->getAuthorPHID()]->renderLink(),
phutil_escape_html($population),
phutil_escape_html($status),
phutil_escape_html($tasks_amount),
// phutil_escape_html($revisions_amount),
phutil_render_tag(
'a',
array(
'href' => '/maniphest/view/all/?projects='.$phid,
),
phutil_escape_html($task_count)),
phutil_render_tag(
'a',
array(
@@ -98,12 +104,11 @@ class PhabricatorProjectListController
$table->setHeaders(
array(
'Project',
'Blurb',
'Description',
'Mastermind',
'Population',
'Status',
'Open Tasks',
// 'Open Revisions',
'',
));
$table->setColumnClasses(
@@ -112,9 +117,8 @@ class PhabricatorProjectListController
'wide',
'',
'right',
'pri',
'',
'right',
// 'right',
'action',
));

View File

@@ -6,14 +6,13 @@
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/maniphest/query');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'applications/project/constants/status');
phutil_require_module('phabricator', 'applications/project/controller/base');
phutil_require_module('phabricator', 'applications/project/storage/affiliation');
phutil_require_module('phabricator', 'applications/project/storage/profile');
phutil_require_module('phabricator', 'applications/project/storage/project');
phutil_require_module('phabricator', 'applications/project/transactions/search');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/layout/panel');