about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/index.scm24
1 files changed, 16 insertions, 8 deletions
diff --git a/scripts/index.scm b/scripts/index.scm
index 87e32f8..e812f94 100644
--- a/scripts/index.scm
+++ b/scripts/index.scm
@@ -123,10 +123,13 @@
 ;;; Database handles
 
 (define (open-writable index rebuild)
-  (unless rebuild
-    ;; Xapian creates its files inside DIR, but not DIR.
-    (unless (zero? (system* "mkdir" "-p" index))
-      (die "could not create ~a" index)))
+  ;; Xapian creates its files inside DIR, but not DIR -- and only the plain
+  ;; `update' path used to create it, so `update --rebuild' on a store whose
+  ;; index directory was deleted (the documented way to recover, and the state
+  ;; of every store that has never been indexed) died in new-WritableDatabase
+  ;; with "mkdir failed". `mkdir -p' is a no-op when the directory is there.
+  (unless (zero? (system* "mkdir" "-p" index))
+    (die "could not create ~a" index))
   (new-WritableDatabase index
                         (if rebuild (DB-CREATE-OR-OVERWRITE) (DB-CREATE-OR-OPEN))))
 
@@ -197,12 +200,18 @@
   (let ((entry (assq key record)))
     (and entry (second entry))))
 
+;;; The title is the entry's own gist -- the assessed one-line claim, which is
+;;; what `list' and `why' show. It is deliberately NOT the subject of the
+;;; commit the entry is attached to: that subject is already the title of the
+;;; commit document, and an entry recorded with `--commit none' has no commit
+;;; to borrow from, which left it indexed with an empty title and its gist
+;;; unsearchable.
 (define (reasoning-record repo row)
   (match row
-    ((id session step kind body commit_hash created_at subject)
+    ((id session step kind body commit_hash created_at gist)
      (let* ((key (format #f "reasoning:~a" id))
             (date (yyyymmdd created_at))
-            (title (if (string? subject) (string-trim-both subject) ""))
+            (title (if (string? gist) (string-trim-both gist) ""))
             (topics (if (non-empty-string? session)
                         (map (lambda (word) (term "O" word))
                              (string-split session #\-))
@@ -334,9 +343,8 @@
   (let ((db (sqlite-open store SQLITE_OPEN_READONLY)))
     (let ((reasoning (query db "SELECT r.id, r.session_id, r.step, r.kind, r.body,
                                       COALESCE(r.commit_hash, ''), r.created_at,
-                                      COALESCE(c.subject, '')
+                                      COALESCE(r.gist, '')
                                FROM reasoning r
-                               LEFT JOIN commits c ON c.hash = r.commit_hash
                                ORDER BY r.id"))
           (commits (query db "SELECT hash, subject, COALESCE(body, ''), author_ts
                               FROM commits ORDER BY author_ts"))