jenkins-bot has submitted this change and it was merged.

Change subject: Return timestamp from index rather than database
......................................................................


Return timestamp from index rather than database

This gives us a really quick way to the last revision that made it into
Cirrus.

Fun fact: the only reason we now load the latest revision of all results
is to check if there is one in the \SearchResult->isMissingRevision.  I
wonder if we can improve page load times by skipping even that somehow....

Bug: 60004

Change-Id: I2c8917167ce4e49ba820661eedcc610d636ce67d
---
M includes/Result.php
M includes/ResultsType.php
2 files changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Result.php b/includes/Result.php
index f7ebbd6..5dca44b 100644
--- a/includes/Result.php
+++ b/includes/Result.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace CirrusSearch;
+use \MWTimestamp;
 use \SearchResult;
 use \Title;
 
@@ -39,6 +40,7 @@
        private $wordCount;
        private $byteSize;
        private $score;
+       private $timestamp;
 
        /**
         * Build the result.
@@ -54,6 +56,7 @@
                // TODO remove ternary once text.word_count is available 
everywhere
                $this->wordCount = isset( $data['text.word_count'] ) ? 
$data['text.word_count'] : $result->text_words;
                $this->byteSize = $result->text_bytes;
+               $this->timestamp = new MWTimestamp( $result->timestamp );
                $highlights = $result->getHighlights();
                // TODO remove when Elasticsearch issue 3757 is fixed
                $highlights = $this->swapInPlainHighlighting( $highlights, 
'redirect.title' );
@@ -211,4 +214,8 @@
        public function getScore() {
                return $this->score;
        }
+
+       public function getTimestamp() {
+               return $this->timestamp->getTimestamp( TS_MW );
+       }
 }
\ No newline at end of file
diff --git a/includes/ResultsType.php b/includes/ResultsType.php
index 392b45a..76bfe3c 100644
--- a/includes/ResultsType.php
+++ b/includes/ResultsType.php
@@ -60,7 +60,8 @@
 class FullTextResultsType implements ResultsType {
        public function getFields() {
                // TODO remove text_words once text.word_count is available 
everywhere
-               return array( 'id', 'title', 'namespace', 'redirect', 
'text_bytes', 'text.word_count', 'text_words' );
+               return array( 'id', 'title', 'namespace', 'redirect', 
'timestamp',
+                       'text_bytes', 'text.word_count', 'text_words' );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/107373
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2c8917167ce4e49ba820661eedcc610d636ce67d
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to