Page MenuHomePhabricator

D16600.id39962.diff
No OneTemporary

D16600.id39962.diff

diff --git a/resources/sql/autopatches/20160927.phurl.ngrams.php b/resources/sql/autopatches/20160927.phurl.ngrams.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160927.phurl.ngrams.php
@@ -0,0 +1,11 @@
+<?php
+
+$table = new PhabricatorPhurlURL();
+
+foreach (new LiskMigrationIterator($table) as $url) {
+ PhabricatorSearchWorker::queueDocumentForIndexing(
+ $url->getPHID(),
+ array(
+ 'force' => true,
+ ));
+}
diff --git a/resources/sql/autopatches/20160927.phurl.ngrams.sql b/resources/sql/autopatches/20160927.phurl.ngrams.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160927.phurl.ngrams.sql
@@ -0,0 +1,7 @@
+CREATE TABLE {$NAMESPACE}_phurl.phurl_phurlname_ngrams (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ objectID INT UNSIGNED NOT NULL,
+ ngram CHAR(3) NOT NULL COLLATE {$COLLATE_TEXT},
+ KEY `key_object` (objectID),
+ KEY `key_ngram` (ngram, objectID)
+) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3187,14 +3187,17 @@
'PhabricatorPhurlURLAccessController' => 'applications/phurl/controller/PhabricatorPhurlURLAccessController.php',
'PhabricatorPhurlURLCommentController' => 'applications/phurl/controller/PhabricatorPhurlURLCommentController.php',
'PhabricatorPhurlURLCreateCapability' => 'applications/phurl/capability/PhabricatorPhurlURLCreateCapability.php',
+ 'PhabricatorPhurlURLEditConduitAPIMethod' => 'applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php',
'PhabricatorPhurlURLEditController' => 'applications/phurl/controller/PhabricatorPhurlURLEditController.php',
'PhabricatorPhurlURLEditEngine' => 'applications/phurl/editor/PhabricatorPhurlURLEditEngine.php',
'PhabricatorPhurlURLEditor' => 'applications/phurl/editor/PhabricatorPhurlURLEditor.php',
'PhabricatorPhurlURLListController' => 'applications/phurl/controller/PhabricatorPhurlURLListController.php',
'PhabricatorPhurlURLMailReceiver' => 'applications/phurl/mail/PhabricatorPhurlURLMailReceiver.php',
+ 'PhabricatorPhurlURLNameNgrams' => 'applications/phurl/storage/PhabricatorPhurlURLNameNgrams.php',
'PhabricatorPhurlURLPHIDType' => 'applications/phurl/phid/PhabricatorPhurlURLPHIDType.php',
'PhabricatorPhurlURLQuery' => 'applications/phurl/query/PhabricatorPhurlURLQuery.php',
'PhabricatorPhurlURLReplyHandler' => 'applications/phurl/mail/PhabricatorPhurlURLReplyHandler.php',
+ 'PhabricatorPhurlURLSearchConduitAPIMethod' => 'applications/phurl/conduit/PhabricatorPhurlURLSearchConduitAPIMethod.php',
'PhabricatorPhurlURLSearchEngine' => 'applications/phurl/query/PhabricatorPhurlURLSearchEngine.php',
'PhabricatorPhurlURLTransaction' => 'applications/phurl/storage/PhabricatorPhurlURLTransaction.php',
'PhabricatorPhurlURLTransactionComment' => 'applications/phurl/storage/PhabricatorPhurlURLTransactionComment.php',
@@ -8104,18 +8107,23 @@
'PhabricatorMentionableInterface',
'PhabricatorFlaggableInterface',
'PhabricatorSpacesInterface',
+ 'PhabricatorConduitResultInterface',
+ 'PhabricatorNgramsInterface',
),
'PhabricatorPhurlURLAccessController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLCommentController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLCreateCapability' => 'PhabricatorPolicyCapability',
+ 'PhabricatorPhurlURLEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'PhabricatorPhurlURLEditController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLEditEngine' => 'PhabricatorEditEngine',
'PhabricatorPhurlURLEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorPhurlURLListController' => 'PhabricatorPhurlController',
'PhabricatorPhurlURLMailReceiver' => 'PhabricatorObjectMailReceiver',
+ 'PhabricatorPhurlURLNameNgrams' => 'PhabricatorSearchNgrams',
'PhabricatorPhurlURLPHIDType' => 'PhabricatorPHIDType',
'PhabricatorPhurlURLQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorPhurlURLReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
+ 'PhabricatorPhurlURLSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'PhabricatorPhurlURLSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorPhurlURLTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorPhurlURLTransactionComment' => 'PhabricatorApplicationTransactionComment',
diff --git a/src/applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php b/src/applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phurl/conduit/PhabricatorPhurlURLEditConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorPhurlURLEditConduitAPIMethod
+ extends PhabricatorEditEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'phurls.edit';
+ }
+
+ public function newEditEngine() {
+ return new PhabricatorPhurlURLEditEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht(
+ 'Apply transactions to create a new Phurl URL or edit an existing one.');
+ }
+}
diff --git a/src/applications/phurl/conduit/PhabricatorPhurlURLSearchConduitAPIMethod.php b/src/applications/phurl/conduit/PhabricatorPhurlURLSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phurl/conduit/PhabricatorPhurlURLSearchConduitAPIMethod.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorPhurlURLSearchConduitAPIMethod
+ extends PhabricatorSearchEngineAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'phurls.search';
+ }
+
+ public function newSearchEngine() {
+ return new PhabricatorPhurlURLSearchEngine();
+ }
+
+ public function getMethodSummary() {
+ return pht('Read information about Phurl URLS.');
+ }
+
+}
diff --git a/src/applications/phurl/query/PhabricatorPhurlURLQuery.php b/src/applications/phurl/query/PhabricatorPhurlURLQuery.php
--- a/src/applications/phurl/query/PhabricatorPhurlURLQuery.php
+++ b/src/applications/phurl/query/PhabricatorPhurlURLQuery.php
@@ -29,6 +29,12 @@
return $this;
}
+ public function withNameNgrams($ngrams) {
+ return $this->withNgramsConstraint(
+ id(new PhabricatorPhurlURLNameNgrams()),
+ $ngrams);
+ }
+
public function withLongURLs(array $long_urls) {
$this->longURLs = $long_urls;
return $this;
diff --git a/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php b/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php
--- a/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php
+++ b/src/applications/phurl/query/PhabricatorPhurlURLSearchEngine.php
@@ -25,6 +25,19 @@
->setLabel(pht('Created By'))
->setKey('authorPHIDs')
->setDatasource(new PhabricatorPeopleUserFunctionDatasource()),
+ id(new PhabricatorSearchTextField())
+ ->setLabel(pht('Name Contains'))
+ ->setKey('name')
+ ->setDescription(pht('Search for phurl URLs by name substring.')),
+ id(new PhabricatorSearchStringListField())
+ ->setLabel(pht('Aliases'))
+ ->setKey('aliases')
+ ->setDescription(pht('Search for phurl URLs by alias.')),
+ id(new PhabricatorSearchStringListField())
+ ->setLabel(pht('Long URLs'))
+ ->setKey('longurls')
+ ->setDescription(
+ pht('Search for phurl URLs by the non-shortened URL.')),
);
}
@@ -35,6 +48,18 @@
$query->withAuthorPHIDs($map['authorPHIDs']);
}
+ if ($map['name'] !== null) {
+ $query->withNameNgrams($map['name']);
+ }
+
+ if ($map['aliases']) {
+ $query->withAliases($map['aliases']);
+ }
+
+ if ($map['longurls']) {
+ $query->withLongURLs($map['longurls']);
+ }
+
return $query;
}
diff --git a/src/applications/phurl/storage/PhabricatorPhurlURL.php b/src/applications/phurl/storage/PhabricatorPhurlURL.php
--- a/src/applications/phurl/storage/PhabricatorPhurlURL.php
+++ b/src/applications/phurl/storage/PhabricatorPhurlURL.php
@@ -9,7 +9,9 @@
PhabricatorDestructibleInterface,
PhabricatorMentionableInterface,
PhabricatorFlaggableInterface,
- PhabricatorSpacesInterface {
+ PhabricatorSpacesInterface,
+ PhabricatorConduitResultInterface,
+ PhabricatorNgramsInterface {
protected $name;
protected $alias;
@@ -202,4 +204,55 @@
public function getSpacePHID() {
return $this->spacePHID;
}
+
+/* -( PhabricatorConduitResultInterface )---------------------------------- */
+
+
+ public function getFieldSpecificationsForConduit() {
+ return array(
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('name')
+ ->setType('string')
+ ->setDescription(pht('URL name.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('alias')
+ ->setType('string')
+ ->setDescription(pht('The alias for the URL.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('longurl')
+ ->setType('string')
+ ->setDescription(pht('The pre-shortened URL.')),
+ id(new PhabricatorConduitSearchFieldSpecification())
+ ->setKey('description')
+ ->setType('string')
+ ->setDescription(pht('A description of the URL.')),
+ );
+ }
+
+ public function getFieldValuesForConduit() {
+ return array(
+ 'name' => $this->getName(),
+ 'alias' => $this->getAlias(),
+ 'description' => $this->getDescription(),
+ 'urls' => array(
+ 'long' => $this->getLongURL(),
+ 'short' => $this->getRedirectURI(),
+ ),
+ );
+ }
+
+ public function getConduitSearchAttachments() {
+ return array();
+ }
+
+/* -( PhabricatorNgramInterface )------------------------------------------ */
+
+
+ public function newNgrams() {
+ return array(
+ id(new PhabricatorPhurlURLNameNgrams())
+ ->setValue($this->getName()),
+ );
+ }
+
}
diff --git a/src/applications/phurl/storage/PhabricatorPhurlURLNameNgrams.php b/src/applications/phurl/storage/PhabricatorPhurlURLNameNgrams.php
new file mode 100644
--- /dev/null
+++ b/src/applications/phurl/storage/PhabricatorPhurlURLNameNgrams.php
@@ -0,0 +1,18 @@
+<?php
+
+final class PhabricatorPhurlURLNameNgrams
+ extends PhabricatorSearchNgrams {
+
+ public function getNgramKey() {
+ return 'phurlname';
+ }
+
+ public function getColumnName() {
+ return 'name';
+ }
+
+ public function getApplicationName() {
+ return 'phurl';
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 7, 9:42 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7735660
Default Alt Text
D16600.id39962.diff (10 KB)

Event Timeline