Changeset 0.29.0 (#195)

This commit is contained in:
2026-03-17 16:28:47 +00:00
parent 128cbb8174
commit 5d637d3a90
129 changed files with 9418 additions and 3016 deletions

View File

@@ -226,3 +226,80 @@ func (s *NoteStore) scanNotes(rows *sql.Rows, total int) ([]models.Note, int, er
}
return result, total, rows.Err()
}
// ── CS5c additions (v0.29.0) ──────────────────────────────────────────
// SetEmbedding is a no-op on SQLite (pgvector is PG-only).
func (s *NoteStore) SetEmbedding(ctx context.Context, noteID, vecStr string) error {
return nil
}
// SearchKeyword performs LIKE-based keyword search on SQLite.
func (s *NoteStore) SearchKeyword(ctx context.Context, userID, query string, limit int) ([]store.NoteSearchResult, error) {
words := strings.Fields(query)
if len(words) == 0 {
return []store.NoteSearchResult{}, nil
}
q := `SELECT id, title, folder_path, tags, SUBSTR(content, 1, 500)
FROM notes WHERE user_id = ?`
args := []interface{}{userID}
for _, w := range words {
pattern := "%" + w + "%"
q += " AND (title LIKE ? OR content LIKE ?)"
args = append(args, pattern, pattern)
}
q += " ORDER BY updated_at DESC LIMIT ?"
args = append(args, limit)
rows, err := DB.QueryContext(ctx, q, args...)
if err != nil {
return nil, err
}
defer rows.Close()
results := make([]store.NoteSearchResult, 0)
for rows.Next() {
var r store.NoteSearchResult
var tagsJSON string
if err := rows.Scan(&r.ID, &r.Title, &r.FolderPath, &tagsJSON, &r.Excerpt); err != nil {
continue
}
r.Tags = ScanArray(tagsJSON)
if r.Tags == nil {
r.Tags = []string{}
}
r.Rank = 1.0 // no ranking on SQLite
results = append(results, r)
}
return results, rows.Err()
}
// SearchSemantic returns empty results on SQLite (vector search requires PG).
func (s *NoteStore) SearchSemantic(ctx context.Context, userID, vecStr string, limit int) ([]store.NoteSearchResult, error) {
return []store.NoteSearchResult{}, nil
}
func (s *NoteStore) ListFolders(ctx context.Context, userID string) ([]store.FolderInfo, error) {
rows, err := DB.QueryContext(ctx, `
SELECT DISTINCT folder_path, COUNT(*) AS count
FROM notes WHERE user_id = ?
GROUP BY folder_path
ORDER BY folder_path
`, userID)
if err != nil {
return nil, err
}
defer rows.Close()
results := make([]store.FolderInfo, 0)
for rows.Next() {
var f store.FolderInfo
if err := rows.Scan(&f.Path, &f.Count); err != nil {
continue
}
results = append(results, f)
}
return results, rows.Err()
}