vole
Clone
Read only, no credentials:
https://rodent.software/git/vole.git
Write over SSH with a registered key:
git clone ssh://git@0.0.0.0:2222/vole.git
A free and open-source forge that lives in your Git repo.
Add a search table over the whole metadata branch
6762a520b7af700dfebd7f613e1a610a42631139 · Keenan Nemetz · 10d ago · parent b739915c
Add a search table over the whole metadata branch Search is the other thing the derived rows are for: one document per issue, change request, and comment, with the title, the body and the author. FTS5 tokenizes them, so a query ranks by relevance instead of scanning every body, and `#42` or a ULID prefix is answered from the numbering table first so the entity someone named comes first. The documents are maintained by the same refresh as the list rows: an entity's text is replaced with the entity, a thread's comments are replaced with the thread, and a deletion removes both. A comment row carries the parent's title and id, so a result can say what it is on and link to the fragment without a second read. The store never decides visibility: Search takes the repository ids the caller may show, and returns nothing outside them. This needs SQLite's FTS5 module. The build tag that enables it in the driver's bundled copy is added to the build commands in the next commit; a build without it fails at index.Open with that reason.
forge/index/comments.go +13−1
| @@ -22,12 +22,19 @@ const ( | |||
| 22 | 22 | // replaceComments replaces one entity's comments. Deleting before inserting is | |
| 23 | 23 | // what makes an edit or a deletion visible; the caller has already replaced the | |
| 24 | 24 | // entity's own row in the same transaction. | |
| 25 | func replaceComments(tx execer, repoID, kind, parent string, comments []metadata.Comment) error { | ||
| 25 | func replaceComments(tx execer, repoID, kind, parent, title string, comments []metadata.Comment) error { | ||
| 26 | 26 | if _, err := tx.Exec( | |
| 27 | 27 | `DELETE FROM comments WHERE repo_id=? AND kind=? AND parent=?`, | |
| 28 | 28 | repoID, kind, parent); err != nil { | |
| 29 | 29 | return err | |
| 30 | 30 | } | |
| 31 | // The search rows for the thread go with the thread, so an edited or deleted | ||
| 32 | // comment cannot survive in a query. | ||
| 33 | if _, err := tx.Exec( | ||
| 34 | `DELETE FROM search WHERE repo_id=? AND kind=? AND parent_id=?`, | ||
| 35 | repoID, commentKindFor(kind), parent); err != nil { | ||
| 36 | return err | ||
| 37 | } | ||
| 31 | 38 | for i := range comments { | |
| 32 | 39 | c := &comments[i] | |
| 33 | 40 | var path, side, blob string | |
| @@ -47,6 +54,11 @@ func replaceComments(tx execer, repoID, kind, parent string, comments []metadata | |||
| 47 | 54 | c.ReplyTo, deleted, path, side, line, blob); err != nil { | |
| 48 | 55 | return err | |
| 49 | 56 | } | |
| 57 | // The title is the parent's, so a result row can say what the comment is | ||
| 58 | // on without a second read; a tombstone keeps no searchable body. | ||
| 59 | if err := indexDocument(tx, repoID, commentKindFor(kind), c.ID, parent, title, c.Author, c.Body); err != nil { | ||
| 60 | return err | ||
| 61 | } | ||
| 50 | 62 | } | |
| 51 | 63 | return nil | |
| 52 | 64 | } | |