diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2012-09-27 23:18:21 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2012-09-27 23:18:21 +0200 |
| commit | aeb9aeb648cdaf28e2872c88687933bb3add821c (patch) | |
| tree | 374b93f7e6e537967474bc2bffb7d498a396347a | |
| parent | c9610f1e514f31982e2d9e79b5ad9b6037551b68 (diff) | |
| download | phorkie-aeb9aeb648cdaf28e2872c88687933bb3add821c.tar.gz phorkie-aeb9aeb648cdaf28e2872c88687933bb3add821c.zip | |
Fix bug #22: Edited pastes not in "recently created"
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | NEWS.rst | 1 | ||||
| -rw-r--r-- | src/phorkie/Database/Adapter/Elasticsearch/Indexer.php | 26 |
3 files changed, 31 insertions, 0 deletions
@@ -1,3 +1,7 @@ +2012-09-27 Christian Weiske <cweiske@bogo> + + * Fix bug #22: Edited pastes not in "recently created" + 2012-09-27 Christian Weiske <cweiske@cweiske.de> * Release of version 0.3.0 @@ -3,6 +3,7 @@ Version 0.3.0 - 2012-09-27 * Fix bug #10: error when nothing submitted [cweiske] * Fix bug #11: do not index edit, delete and tool pages [cweiske] +* Fix bug #22: Edited pastes not in "recently created" [cweiske] * Implement request #5: Add OpenID authentication [jnovack] * Implement request #9: autodetect file type [cweiske] * Implement request #12: DOAP and rel="vcs-git" support [cweiske] diff --git a/src/phorkie/Database/Adapter/Elasticsearch/Indexer.php b/src/phorkie/Database/Adapter/Elasticsearch/Indexer.php index 41aa7d7..dbe769e 100644 --- a/src/phorkie/Database/Adapter/Elasticsearch/Indexer.php +++ b/src/phorkie/Database/Adapter/Elasticsearch/Indexer.php @@ -29,9 +29,13 @@ class Database_Adapter_Elasticsearch_Indexer implements Database_IIndexer 'description' => $repo->getDescription(), 'tstamp' => gmdate('c', time()), ); + if ($crdate == null) { + $crdate = $this->getCrDate($repo); + } if ($crdate !== null) { $repoData['crdate'] = gmdate('c', $crdate); } + $r->setBody(json_encode((object)$repoData)); $r->send(); @@ -57,6 +61,28 @@ class Database_Adapter_Elasticsearch_Indexer implements Database_IIndexer } } + /** + * When updating the repository, we don't have a creation date. + * We need to keep it, but elasticsearch does not have a simple way + * to update some fields only (without using a custom script). + * + * @return integer Unix timestamp + */ + protected function getCrDate(Repository $repo) + { + $r = new Database_Adapter_Elasticsearch_HTTPRequest( + $this->searchInstance . 'repo/' . $repo->id, + \HTTP_Request2::METHOD_GET + ); + $json = json_decode($r->send()->getBody()); + + if (!isset($json->_source->crdate)) { + return null; + } + + return strtotime($json->_source->crdate); + } + public function deleteAllRepos() { $r = new Database_Adapter_Elasticsearch_HTTPRequest( |
