summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tissue/commit.scm4
-rw-r--r--tissue/document.scm10
-rw-r--r--tissue/file-document.scm4
3 files changed, 17 insertions, 1 deletions
diff --git a/tissue/commit.scm b/tissue/commit.scm
index 2ff6553..30d07b7 100644
--- a/tissue/commit.scm
+++ b/tissue/commit.scm
@@ -42,6 +42,10 @@
"Return the ID term for DOCUMENT."
(string-append "Qcommit." (commit-hash commit)))
+(define-method (document-recency-date (commit <commit>))
+ "Return a date representing the recency of DOCUMENT"
+ (doc:commit-author-date commit))
+
(define-method (document-term-generator (commit <commit>))
"Return a term generator indexing COMMIT."
(let ((term-generator (next-method)))
diff --git a/tissue/document.scm b/tissue/document.scm
index ef3ca21..ecdabc3 100644
--- a/tissue/document.scm
+++ b/tissue/document.scm
@@ -37,6 +37,7 @@
document-type
document-id-term
document-text
+ document-recency-date
document-term-generator
document-snippet-source-text
document-snippet
@@ -133,6 +134,7 @@ that operates on a copy of OBJECT. It does not mutate OBJECT."
(define-generic document-id-term)
(define-generic document-text)
+(define-generic document-recency-date)
(define-generic print)
(define-generic document->sxml)
@@ -151,7 +153,13 @@ and further text, increase-termpos! must be called before indexing."
#:document (make-document
#:data (call-with-output-string
(cut write (object->scm document) <>))
- #:terms `((,(document-id-term document) . 0))))))
+ #:terms `((,(document-id-term document) . 0))
+ ;; This serialization of the recency date gets
+ ;; the timezone ordering wrong. TODO: Replace it
+ ;; with sortable-serialise once it is working in
+ ;; guile-xapian.
+ #:values `((0 . ,(date->iso-8601
+ (document-recency-date document))))))))
(index-text! term-generator (document-type document) #:prefix "XT")
(index-text! term-generator (document-title document) #:prefix "S")
(index-text! term-generator (document-text document))
diff --git a/tissue/file-document.scm b/tissue/file-document.scm
index 112c7f2..1265660 100644
--- a/tissue/file-document.scm
+++ b/tissue/file-document.scm
@@ -64,6 +64,10 @@
"Return the ID term for DOCUMENT."
(string-append "Qfile." (file-document-path document)))
+(define-method (document-recency-date (document <file-document>))
+ "Return a date representing the recency of DOCUMENT."
+ (file-document-last-updated-date document))
+
(define-method (document-text (document <file-document>))
"Return the full text of DOCUMENT."
(call-with-file-in-git (current-git-repository) (file-document-path document)