diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index cddac1af23..dbfcc996fd 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -457,7 +457,6 @@ phutil_register_library_map(array( 'PhabricatorProjectProfileController' => 'applications/project/controller/profile', 'PhabricatorProjectProfileEditController' => 'applications/project/controller/profileedit', 'PhabricatorProjectStatus' => 'applications/project/constants/status', - 'PhabricatorProjectTransactionSearch' => 'applications/project/transactions/search', 'PhabricatorRedirectController' => 'applications/base/controller/redirect', 'PhabricatorRemarkupRuleDifferential' => 'infrastructure/markup/remarkup/markuprule/differential', 'PhabricatorRemarkupRuleDiffusion' => 'infrastructure/markup/remarkup/markuprule/diffusion', diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index 08f543dcc3..4289613735 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -29,6 +29,7 @@ final class ManiphestTaskQuery { private $includeUnowned = null; private $projectPHIDs = array(); private $subscriberPHIDs = array(); + private $anyProject = false; private $status = 'status-any'; const STATUS_ANY = 'status-any'; @@ -129,6 +130,11 @@ final class ManiphestTaskQuery { return $this->rowCount; } + public function withAnyProject($any_project) { + $this->anyProject = $any_project; + return $this; + } + public function execute() { $task_dao = new ManiphestTask(); @@ -176,14 +182,18 @@ final class ManiphestTaskQuery { // multiple times. We use GROUP BY to make them distinct again. // - We want to treat the query as an intersection query, not a union // query. We sum the project count and require it be the same as the - // number of projects we're searching for. + // number of projects we're searching for. (If 'anyProject' is set, + // we do union instead.) $group = 'GROUP BY task.id'; - $count = ', COUNT(1) projectCount'; - $having = qsprintf( - $conn, - 'HAVING projectCount = %d', - count($this->projectPHIDs)); + + if (!$this->anyProject) { + $count = ', COUNT(1) projectCount'; + $having = qsprintf( + $conn, + 'HAVING projectCount = %d', + count($this->projectPHIDs)); + } } $order = $this->buildOrderClause($conn); diff --git a/src/applications/project/constants/status/PhabricatorProjectStatus.php b/src/applications/project/constants/status/PhabricatorProjectStatus.php index d933249636..1bce8fa0e5 100644 --- a/src/applications/project/constants/status/PhabricatorProjectStatus.php +++ b/src/applications/project/constants/status/PhabricatorProjectStatus.php @@ -30,7 +30,7 @@ final class PhabricatorProjectStatus { public static function getNameForStatus($status) { static $map = array( - self::UNKNOWN => 'Who knows?', + self::UNKNOWN => '', self::NOT_STARTED => 'Not started', self::IN_PROGRESS => 'In progress', self::ONGOING => 'Ongoing', diff --git a/src/applications/project/controller/list/PhabricatorProjectListController.php b/src/applications/project/controller/list/PhabricatorProjectListController.php index 759b8c1c61..05faacf307 100644 --- a/src/applications/project/controller/list/PhabricatorProjectListController.php +++ b/src/applications/project/controller/list/PhabricatorProjectListController.php @@ -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', )); diff --git a/src/applications/project/controller/list/__init__.php b/src/applications/project/controller/list/__init__.php index c7ff3c35e3..c87483a57d 100644 --- a/src/applications/project/controller/list/__init__.php +++ b/src/applications/project/controller/list/__init__.php @@ -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'); diff --git a/src/applications/project/transactions/search/PhabricatorProjectTransactionSearch.php b/src/applications/project/transactions/search/PhabricatorProjectTransactionSearch.php deleted file mode 100644 index 02e569c81b..0000000000 --- a/src/applications/project/transactions/search/PhabricatorProjectTransactionSearch.php +++ /dev/null @@ -1,55 +0,0 @@ -projectPhids = $project_phids; - } else { - $this->projectPhids = array($project_phids); - } - return $this; - } - - // search all open documents by default - public function setSearchOptions($documents = '', $status = true) { - $this->documents = $documents; - $this->status = $status; - return $this; - } - - public function executeSearch() { - $projects = $this->projectPhids; - $on_documents = $this->documents; - $with_status = $this->status; - - $query = new PhabricatorSearchQuery(); - $query->setQuery(''); - $query->setParameter('project', $projects); - $query->setParameter('type', $on_documents); - $query->setParameter('open', $with_status); - - $executor = new PhabricatorSearchMySQLExecutor(); - $results = $executor->executeSearch($query); - return $results; - } -} diff --git a/src/applications/project/transactions/search/__init__.php b/src/applications/project/transactions/search/__init__.php deleted file mode 100644 index 722f521d91..0000000000 --- a/src/applications/project/transactions/search/__init__.php +++ /dev/null @@ -1,13 +0,0 @@ -