Page MenuHomePhabricator

D13793.id33313.diff
No OneTemporary

D13793.id33313.diff

diff --git a/src/applications/ponder/query/PonderQuestionQuery.php b/src/applications/ponder/query/PonderQuestionQuery.php
--- a/src/applications/ponder/query/PonderQuestionQuery.php
+++ b/src/applications/ponder/query/PonderQuestionQuery.php
@@ -8,6 +8,8 @@
private $authorPHIDs;
private $answererPHIDs;
+ private $needProjects;
+
private $status = 'status-any';
const STATUS_ANY = 'status-any';
@@ -52,6 +54,11 @@
return $this;
}
+ public function needProjects($need_projects) {
+ $this->needProjects = $need_projects;
+ return $this;
+ }
+
protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = parent::buildWhereClauseParts($conn);
@@ -109,6 +116,9 @@
}
protected function willFilterPage(array $questions) {
+
+ $phids = mpull($questions, 'getPHID');
+
if ($this->needAnswers) {
$aquery = id(new PonderAnswerQuery())
->setViewer($this->getViewer())
@@ -133,7 +143,7 @@
$etype = PonderQuestionHasVotingUserEdgeType::EDGECONST;
$edges = id(new PhabricatorEdgeQuery())
- ->withSourcePHIDs(mpull($questions, 'getPHID'))
+ ->withSourcePHIDs($phids)
->withDestinationPHIDs(array($viewer_phid))
->withEdgeTypes(array($etype))
->needEdgeData(true)
@@ -148,6 +158,22 @@
}
}
+ if ($this->needProjects) {
+ $edge_query = id(new PhabricatorEdgeQuery())
+ ->withSourcePHIDs($phids)
+ ->withEdgeTypes(
+ array(
+ PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
+ ));
+ $edge_query->execute();
+
+ foreach ($questions as $question) {
+ $project_phids = $edge_query->getDestinationPHIDs(
+ array($question->getPHID()));
+ $question->attachProjectPHIDs($project_phids);
+ }
+ }
+
return $questions;
}
diff --git a/src/applications/ponder/query/PonderQuestionSearchEngine.php b/src/applications/ponder/query/PonderQuestionSearchEngine.php
--- a/src/applications/ponder/query/PonderQuestionSearchEngine.php
+++ b/src/applications/ponder/query/PonderQuestionSearchEngine.php
@@ -12,7 +12,8 @@
}
public function newQuery() {
- return new PonderQuestionQuery();
+ return id(new PonderQuestionQuery())
+ ->needProjects(true);
}
protected function buildQueryFromParameters(array $map) {
@@ -64,8 +65,8 @@
protected function getBuiltinQueryNames() {
$names = array(
- 'open' => pht('Open Questions'),
'all' => pht('All Questions'),
+ 'open' => pht('Open Questions'),
);
if ($this->requireViewer()->isLoggedIn()) {
@@ -112,6 +113,18 @@
$viewer = $this->requireViewer();
+ $proj_phids = array();
+ foreach ($questions as $question) {
+ foreach ($question->getProjectPHIDs() as $project_phid) {
+ $proj_phids[] = $project_phid;
+ }
+ }
+
+ $proj_handles = id(new PhabricatorHandleQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($proj_phids)
+ ->execute();
+
$view = id(new PHUIObjectItemListView())
->setUser($viewer);
@@ -129,6 +142,10 @@
$item->setObject($question);
$item->setStatusIcon($icon.' '.$color, $full_status);
+ $project_handles = array_select_keys(
+ $proj_handles,
+ $question->getProjectPHIDs());
+
$created_date = phabricator_date($question->getDateCreated(), $viewer);
$item->addIcon('none', $created_date);
$item->addByline(
@@ -139,6 +156,14 @@
$item->addAttribute(
pht('%d Answer(s)', $question->getAnswerCount()));
+ if ($project_handles) {
+ $item->addAttribute(
+ id(new PHUIHandleTagListView())
+ ->setLimit(4)
+ ->setSlim(true)
+ ->setHandles($project_handles));
+ }
+
$view->addItem($item);
}
diff --git a/src/applications/ponder/storage/PonderQuestion.php b/src/applications/ponder/storage/PonderQuestion.php
--- a/src/applications/ponder/storage/PonderQuestion.php
+++ b/src/applications/ponder/storage/PonderQuestion.php
@@ -33,6 +33,8 @@
private $vote;
private $comments;
+ private $edgeProjectPHIDs = self::ATTACHABLE;
+
public static function initializeNewQuestion(PhabricatorUser $actor) {
$app = id(new PhabricatorApplicationQuery())
->setViewer($actor)
@@ -164,6 +166,15 @@
return $this->answers;
}
+ public function getProjectPHIDs() {
+ return $this->assertAttached($this->edgeProjectPHIDs);
+ }
+
+ public function attachProjectPHIDs(array $phids) {
+ $this->edgeProjectPHIDs = $phids;
+ return $this;
+ }
+
public function getMarkupField() {
return self::MARKUP_FIELD_CONTENT;
}
diff --git a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
--- a/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
+++ b/src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
@@ -32,6 +32,8 @@
'%d path(s)' => array('%d path', '%d paths'),
'%d diff(s)' => array('%d diff', '%d diffs'),
+ '%d Answer(s)' => array('%d Answer', '%d Answers'),
+
'%s DIFF LINK(S)' => array('DIFF LINK', 'DIFF LINKS'),
'You successfully created %d diff(s).' => array(
'You successfully created %d diff.',

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 20, 6:55 AM (12 h, 13 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6622806
Default Alt Text
D13793.id33313.diff (5 KB)

Event Timeline