1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-01 19:22:42 +01:00

Implement saving queries.

Summary: Enable saved query objects to actually be saved to the database.

Test Plan: Insert a call to save() and check that the query is written correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D5775

Conflicts:

	src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php
This commit is contained in:
Bryan Cuccioli 2013-04-30 10:47:10 -07:00 committed by epriestley
parent c7be6f4aa1
commit 7ad2eae47f
3 changed files with 28 additions and 0 deletions

View file

@ -0,0 +1,11 @@
CREATE TABLE {$NAMESPACE}_search.search_savedquery (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
engineClassName VARCHAR(255) NOT NULL COLLATE utf8_bin,
parameters LONGTEXT NOT NULL COLLATE utf8_bin,
dateCreated INT(10) UNSIGNED NOT NULL,
dateModified INT(10) UNSIGNED NOT NULL,
queryKey VARCHAR(12) NOT NULL COLLATE utf8_bin,
PRIMARY KEY(id),
UNIQUE KEY key_queryKey (queryKey)
)
ENGINE=InnoDB, COLLATE utf8_general_ci

View file

@ -6,6 +6,8 @@
final class PhabricatorSavedQuery extends PhabricatorSearchDAO { final class PhabricatorSavedQuery extends PhabricatorSearchDAO {
protected $parameters = array(); protected $parameters = array();
protected $queryKey = "";
protected $engineClassName = "PhabricatorPasteSearchEngine";
public function getConfiguration() { public function getConfiguration() {
return array( return array(
@ -22,4 +24,15 @@ final class PhabricatorSavedQuery extends PhabricatorSearchDAO {
public function getParameter($key, $default = null) { public function getParameter($key, $default = null) {
return idx($this->parameters, $key, $default); return idx($this->parameters, $key, $default);
} }
public function save() {
if ($this->getEngineClass() === null) {
throw new Exception(pht("Engine class is null."));
}
$serial = $this->getEngineClass().serialize($this->parameters);
$this->queryKey = PhabricatorHash::digestForIndex($serial);
return parent::save();
}
} }

View file

@ -1254,6 +1254,10 @@ final class PhabricatorBuiltinPatchList extends PhabricatorSQLPatchList {
'type' => 'sql', 'type' => 'sql',
'name' => $this->getPatchPath('20130423.conpherenceindices.sql'), 'name' => $this->getPatchPath('20130423.conpherenceindices.sql'),
), ),
'20130426.search_savedquery.sql' => array(
'type' => 'sql',
'name' => $this->getPatchPath('20130426.search_savedquery.sql'),
),
); );
} }
} }