Differential D17300 Diff 41609 src/applications/repository/search/PhabricatorRepositoryFulltextEngine.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/search/PhabricatorRepositoryFulltextEngine.php
- This file was added.
<?php | |||||
final class PhabricatorRepositoryFulltextEngine | |||||
extends PhabricatorFulltextEngine { | |||||
protected function buildAbstractDocument( | |||||
PhabricatorSearchAbstractDocument $document, | |||||
$object) { | |||||
/** @var PhabricatorRepository $repository the repository */ | |||||
epriestley: This kind of documentation is unconventional in this codebase, and the docs say `$repository`… | |||||
20after4AuthorUnsubmitted Not Done Inline ActionsI was trying to get code intelligence to act intelligently. It didn't work and I forgot to delete the comment. Code intelligence: still not very intelligent in 2017. 20after4: I was trying to get code intelligence to act intelligently. It didn't work and I forgot to… | |||||
$repo = $object; | |||||
$document->setDocumentTitle($repo->getName()); | |||||
$document->addField( | |||||
PhabricatorSearchDocumentFieldType::FIELD_BODY, | |||||
Not Done Inline ActionsI guess I could actually add the field twice instead of concatenating with a \n, at least that works fine with elasticsearch. I wonder how it would work with mysql... 20after4: I guess I could actually add the field twice instead of concatenating with a \n, at least that… | |||||
$repo->getRepositorySlug().': '.$repo->getDetail('description')); | |||||
epriestleyUnsubmitted Done Inline ActionsNewline is probably a better delimiter than colon, since users might reasonably search for "x: y" and get a false/confusing positive here. (In theory, they can search for a newline too, I guess, but not reasonably using the normal UI). epriestley: Newline is probably a better delimiter than colon, since users might reasonably search for `"x… | |||||
20after4AuthorUnsubmitted Not Done Inline ActionsGood point. 20after4: Good point. | |||||
Done Inline Actions'\n' in single quotes isn't a newline in PHP. 🐈 epriestley@orbital ~ $ cat test.php <?php echo "With Double Quotes: <\n>"; echo "\n"; echo 'With Single Quotes: <\n>'; echo "\n"; epriestley@orbital ~ $ php -f test.php With Double Quotes: < > With Single Quotes: <\n> epriestley: '\n' in single quotes isn't a newline in PHP. 🐈
```
epriestley@orbital ~ $ cat test.php
<? | |||||
Done Inline Actionsdoh! surprised arc doesn't have a lint rule for '\n' ...but I guess there are legitimate uses for it occasionally. 20after4: doh!
thatwasobvious
surprised arc doesn't have a lint rule for '\n' ...but I guess there are… | |||||
$document->setDocumentCreated($repo->getDateCreated()); | |||||
$document->setDocumentModified($repo->getDateModified()); | |||||
$document->addRelationship( | |||||
$repo->isTracked() | |||||
? PhabricatorSearchRelationship::RELATIONSHIP_OPEN | |||||
: PhabricatorSearchRelationship::RELATIONSHIP_CLOSED, | |||||
$repo->getPHID(), | |||||
PhabricatorRepositoryRepositoryPHIDType::TYPECONST, | |||||
PhabricatorTime::getNow()); | |||||
} | |||||
} |
This kind of documentation is unconventional in this codebase, and the docs say $repository while the actual variable is $repo. I think this is perfectly clear from context anyway, just nuke it?