diff options
author | Arun Isaac | 2022-07-13 13:27:30 +0530 |
---|---|---|
committer | Arun Isaac | 2022-07-19 17:37:02 +0530 |
commit | e2fe50c591706a7902048aaef911ce433522a322 (patch) | |
tree | 4da5664ccc7a33667db51358d0fc299683cac7b2 | |
parent | 6fa357a7f5793b29473a5fb1a2476eee38d676d3 (diff) | |
download | tissue-e2fe50c591706a7902048aaef911ce433522a322.tar.gz tissue-e2fe50c591706a7902048aaef911ce433522a322.tar.lz tissue-e2fe50c591706a7902048aaef911ce433522a322.zip |
document: Store serialized date as value in Xapian document.
* tissue/document.scm (document-recency-date): Declare public generic
function.
(document-term-generator): Store serialized date in slot 0 of Xapian
document.
* tissue/file-document.scm (document-recency-date): New generic
method.
* tissue/commit.scm (document-recency-date): New generic method.
-rw-r--r-- | tissue/commit.scm | 4 | ||||
-rw-r--r-- | tissue/document.scm | 10 | ||||
-rw-r--r-- | tissue/file-document.scm | 4 |
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) |