2017-09-07 18:38:19 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorUserFerretEngine
|
|
|
|
extends PhabricatorFerretEngine {
|
|
|
|
|
Reduce the amount of boilerplate that implementing FerretInterface requires
Summary:
See brief discussion in D18554. All the index tables are the same for every application (and, at this point, seem unlikely to change) and we never actually pass these objects around (they're only used internally).
In some other cases (like Transactions) not every application has the same tables (for example, Differential has extra field for inline comments), and/or we pass the objects around (lots of stuff uses `$xactions` directly).
However, in this case, and in Edges, we don't interact with any representation of the database state directly in much of the code, and it doesn't change from application to application.
Just automatically define document, field, and ngram tables for anything which implements `FerretInterface`. This makes the query and index logic a tiny bit messier but lets us delete a ton of boilerplate classes.
Test Plan: Indexed objects, searched for objects. Same results as before with much less code. Ran `bin/storage upgrade`, got a clean bill of health.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T12819
Differential Revision: https://secure.phabricator.com/D18559
2017-09-07 20:03:39 +02:00
|
|
|
public function getApplicationName() {
|
|
|
|
return 'user';
|
2017-09-07 18:38:19 +02:00
|
|
|
}
|
|
|
|
|
Reduce the amount of boilerplate that implementing FerretInterface requires
Summary:
See brief discussion in D18554. All the index tables are the same for every application (and, at this point, seem unlikely to change) and we never actually pass these objects around (they're only used internally).
In some other cases (like Transactions) not every application has the same tables (for example, Differential has extra field for inline comments), and/or we pass the objects around (lots of stuff uses `$xactions` directly).
However, in this case, and in Edges, we don't interact with any representation of the database state directly in much of the code, and it doesn't change from application to application.
Just automatically define document, field, and ngram tables for anything which implements `FerretInterface`. This makes the query and index logic a tiny bit messier but lets us delete a ton of boilerplate classes.
Test Plan: Indexed objects, searched for objects. Same results as before with much less code. Ran `bin/storage upgrade`, got a clean bill of health.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T12819
Differential Revision: https://secure.phabricator.com/D18559
2017-09-07 20:03:39 +02:00
|
|
|
public function getScopeName() {
|
|
|
|
return 'user';
|
2017-09-07 18:38:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function newSearchEngine() {
|
|
|
|
return new PhabricatorPeopleSearchEngine();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getObjectTypeRelevance() {
|
|
|
|
// Always sort users above other documents, regardless of relevance
|
|
|
|
// metrics. A user profile is very likely to be the best hit for a query
|
|
|
|
// which matches a user.
|
|
|
|
return 500;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|