Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/typeahead/PhabricatorProjectDatasource.php
Show All 15 Lines | final class PhabricatorProjectDatasource | ||||
} | } | ||||
public function loadResults() { | public function loadResults() { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$raw_query = $this->getRawQuery(); | $raw_query = $this->getRawQuery(); | ||||
// Allow users to type "#qa" or "qa" to find "Quality Assurance". | // Allow users to type "#qa" or "qa" to find "Quality Assurance". | ||||
if ($raw_query !== null) { | |||||
$raw_query = ltrim($raw_query, '#'); | $raw_query = ltrim($raw_query, '#'); | ||||
} | |||||
valerio.bozzolan: Don't hate me, but I think Evan would love to be able to search by string `"0"` (currently… | |||||
Not Done Inline Actionsvalerio.bozzolan: Hi @aklapper, if you change this small line I will immediately +1 since it would be totally OK… | |||||
$tokens = self::tokenizeString($raw_query); | $tokens = self::tokenizeString($raw_query); | ||||
$query = id(new PhabricatorProjectQuery()) | $query = id(new PhabricatorProjectQuery()) | ||||
->needImages(true) | ->needImages(true) | ||||
->needSlugs(true) | ->needSlugs(true) | ||||
->setOrderVector(array('-status', 'id')); | ->setOrderVector(array('-status', 'id')); | ||||
if ($this->getPhase() == self::PHASE_PREFIX) { | if ($this->getPhase() == self::PHASE_PREFIX) { | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | foreach ($projs as $proj) { | ||||
$proj_result->setAutocomplete('#'.$slug); | $proj_result->setAutocomplete('#'.$slug); | ||||
} | } | ||||
$proj_result->setImageURI($proj->getProfileImageURI()); | $proj_result->setImageURI($proj->getProfileImageURI()); | ||||
if ($is_browse) { | if ($is_browse) { | ||||
$proj_result->addAttribute($proj->getDisplayIconName()); | $proj_result->addAttribute($proj->getDisplayIconName()); | ||||
$description = idx($descriptions, $phid); | $description = idx($descriptions, $phid); | ||||
if (strlen($description)) { | if (phutil_nonempty_string($description)) { | ||||
Done Inline Actions✅ I verified the above line Note that another known alternative could be: $description = idx($descriptions, $phid, ''); if ($description !== '') { But in my honest opinion your already-existing approach is better than the above one and avoids some possible facets. The function phutil_nonempty_string() will report alien values and that is OK. valerio.bozzolan: ✅ I verified the above line
Note that another known alternative could be:
```… | |||||
$summary = PhabricatorMarkupEngine::summarizeSentence($description); | $summary = PhabricatorMarkupEngine::summarizeSentence($description); | ||||
$proj_result->addAttribute($summary); | $proj_result->addAttribute($summary); | ||||
} | } | ||||
} | } | ||||
$results[] = $proj_result; | $results[] = $proj_result; | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
} | } |
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
Don't hate me, but I think Evan would love to be able to search by string "0" (currently skipped since it's falsy)