Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14846357
D13793.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D13793.diff
View Options
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 $needProjectPHIDs;
+
private $status = 'status-any';
const STATUS_ANY = 'status-any';
@@ -52,6 +54,11 @@
return $this;
}
+ public function needProjectPHIDs($need_projects) {
+ $this->needProjectPHIDs = $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->needProjectPHIDs) {
+ $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())
+ ->needProjectPHIDs(true);
}
protected function buildQueryFromParameters(array $map) {
@@ -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 $projectPHIDs = 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->projectPHIDs);
+ }
+
+ public function attachProjectPHIDs(array $phids) {
+ $this->projectPHIDs = $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
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 4, 3:24 AM (21 h, 17 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7088690
Default Alt Text
D13793.diff (5 KB)
Attached To
Mode
D13793: Add Projects to Ponder Search View
Attached
Detach File
Event Timeline
Log In to Comment