Merge commit '52c4d1f' into feat/remote-node
# Conflicts: # internal/db/db.go
This commit is contained in:
@@ -0,0 +1,152 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: entries.sql
|
||||
|
||||
package sqlcdb
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
const countEntries = `-- name: CountEntries :one
|
||||
SELECT COUNT(*) FROM entries
|
||||
`
|
||||
|
||||
func (q *Queries) CountEntries(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, countEntries)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const countObservations = `-- name: CountObservations :one
|
||||
|
||||
SELECT COUNT(*) FROM observations
|
||||
`
|
||||
|
||||
// NOTE: the FTS5 search path is deliberately absent. sqlc ignores
|
||||
// `CREATE VIRTUAL TABLE ... USING fts5`, so `entries_fts` and the bm25()/MATCH
|
||||
// operators are invisible to it. Search stays hand-written in db.go.
|
||||
func (q *Queries) CountObservations(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRowContext(ctx, countObservations)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const getEntry = `-- name: GetEntry :one
|
||||
|
||||
SELECT fingerprint, source_id, COALESCE(source_path,'') AS source_path,
|
||||
COALESCE(project,'') AS project, COALESCE(content_type,'') AS content_type,
|
||||
COALESCE(title,'') AS title, COALESCE(summary,'') AS summary,
|
||||
COALESCE(first_seen,'') AS first_seen, COALESCE(last_seen,'') AS last_seen,
|
||||
COALESCE(created_at,'') AS created_at, ref_count,
|
||||
COALESCE(last_confidence,0.5) AS last_confidence
|
||||
FROM entries
|
||||
WHERE fingerprint = ?
|
||||
`
|
||||
|
||||
type GetEntryRow struct {
|
||||
Fingerprint string
|
||||
SourceID string
|
||||
SourcePath string
|
||||
Project string
|
||||
ContentType string
|
||||
Title string
|
||||
Summary string
|
||||
FirstSeen string
|
||||
LastSeen string
|
||||
CreatedAt string
|
||||
RefCount sql.NullInt64
|
||||
LastConfidence float64
|
||||
}
|
||||
|
||||
// Pilot queries for sqlc: the read paths behind the MCP tools.
|
||||
//
|
||||
// These are the highest-traffic reads and deliberately include the hardest
|
||||
// case (FTS5 MATCH + bm25 ranking) so the pilot proves whether sqlc can cover
|
||||
// the search path, not just the easy table scans.
|
||||
func (q *Queries) GetEntry(ctx context.Context, fingerprint string) (GetEntryRow, error) {
|
||||
row := q.db.QueryRowContext(ctx, getEntry, fingerprint)
|
||||
var i GetEntryRow
|
||||
err := row.Scan(
|
||||
&i.Fingerprint,
|
||||
&i.SourceID,
|
||||
&i.SourcePath,
|
||||
&i.Project,
|
||||
&i.ContentType,
|
||||
&i.Title,
|
||||
&i.Summary,
|
||||
&i.FirstSeen,
|
||||
&i.LastSeen,
|
||||
&i.CreatedAt,
|
||||
&i.RefCount,
|
||||
&i.LastConfidence,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listRecentEntries = `-- name: ListRecentEntries :many
|
||||
SELECT fingerprint, source_id, COALESCE(source_path,'') AS source_path,
|
||||
COALESCE(project,'') AS project, COALESCE(content_type,'') AS content_type,
|
||||
COALESCE(title,'') AS title, COALESCE(summary,'') AS summary,
|
||||
COALESCE(first_seen,'') AS first_seen, COALESCE(last_seen,'') AS last_seen,
|
||||
COALESCE(created_at,'') AS created_at, ref_count,
|
||||
COALESCE(last_confidence,0.5) AS last_confidence
|
||||
FROM entries
|
||||
ORDER BY COALESCE(NULLIF(created_at,''), last_seen) DESC
|
||||
LIMIT ?
|
||||
`
|
||||
|
||||
type ListRecentEntriesRow struct {
|
||||
Fingerprint string
|
||||
SourceID string
|
||||
SourcePath string
|
||||
Project string
|
||||
ContentType string
|
||||
Title string
|
||||
Summary string
|
||||
FirstSeen string
|
||||
LastSeen string
|
||||
CreatedAt string
|
||||
RefCount sql.NullInt64
|
||||
LastConfidence float64
|
||||
}
|
||||
|
||||
func (q *Queries) ListRecentEntries(ctx context.Context, limit int64) ([]ListRecentEntriesRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, listRecentEntries, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
items := []ListRecentEntriesRow{}
|
||||
for rows.Next() {
|
||||
var i ListRecentEntriesRow
|
||||
if err := rows.Scan(
|
||||
&i.Fingerprint,
|
||||
&i.SourceID,
|
||||
&i.SourcePath,
|
||||
&i.Project,
|
||||
&i.ContentType,
|
||||
&i.Title,
|
||||
&i.Summary,
|
||||
&i.FirstSeen,
|
||||
&i.LastSeen,
|
||||
&i.CreatedAt,
|
||||
&i.RefCount,
|
||||
&i.LastConfidence,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
Reference in New Issue
Block a user