You've already forked agentic-coding-workflow
269 lines
7.5 KiB
Go
269 lines
7.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: memory.sql
|
|
|
|
package projectmemorysqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const deleteEntry = `-- name: DeleteEntry :exec
|
|
DELETE FROM project_memory WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteEntry(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteEntry, id)
|
|
return err
|
|
}
|
|
|
|
const getEntry = `-- name: GetEntry :one
|
|
SELECT id, project_id, workspace_id, kind, title, body, tags, source,
|
|
embedding_model, created_by, created_at, updated_at
|
|
FROM project_memory
|
|
WHERE id = $1
|
|
`
|
|
|
|
type GetEntryRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
EmbeddingModel *string `json:"embedding_model"`
|
|
CreatedBy pgtype.UUID `json:"created_by"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) GetEntry(ctx context.Context, id pgtype.UUID) (GetEntryRow, error) {
|
|
row := q.db.QueryRow(ctx, getEntry, id)
|
|
var i GetEntryRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Title,
|
|
&i.Body,
|
|
&i.Tags,
|
|
&i.Source,
|
|
&i.EmbeddingModel,
|
|
&i.CreatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertEntry = `-- name: InsertEntry :one
|
|
|
|
INSERT INTO project_memory (
|
|
id, project_id, workspace_id, kind, title, body, tags, source,
|
|
embedding_model, created_by
|
|
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
RETURNING id, project_id, workspace_id, kind, title, body, tags, source,
|
|
embedding_model, created_by, created_at, updated_at
|
|
`
|
|
|
|
type InsertEntryParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
EmbeddingModel *string `json:"embedding_model"`
|
|
CreatedBy pgtype.UUID `json:"created_by"`
|
|
}
|
|
|
|
type InsertEntryRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
EmbeddingModel *string `json:"embedding_model"`
|
|
CreatedBy pgtype.UUID `json:"created_by"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
// The embedding (vector) column is excluded from sqlc queries (no native pgvector
|
|
// type). Write sets embedding via a hand-written pgx UPDATE; vector KNN search is
|
|
// hand-written in repository.go. These queries cover the non-vector path.
|
|
func (q *Queries) InsertEntry(ctx context.Context, arg InsertEntryParams) (InsertEntryRow, error) {
|
|
row := q.db.QueryRow(ctx, insertEntry,
|
|
arg.ID,
|
|
arg.ProjectID,
|
|
arg.WorkspaceID,
|
|
arg.Kind,
|
|
arg.Title,
|
|
arg.Body,
|
|
arg.Tags,
|
|
arg.Source,
|
|
arg.EmbeddingModel,
|
|
arg.CreatedBy,
|
|
)
|
|
var i InsertEntryRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Title,
|
|
&i.Body,
|
|
&i.Tags,
|
|
&i.Source,
|
|
&i.EmbeddingModel,
|
|
&i.CreatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listByProject = `-- name: ListByProject :many
|
|
SELECT id, project_id, workspace_id, kind, title, body, tags, source,
|
|
embedding_model, created_by, created_at, updated_at
|
|
FROM project_memory
|
|
WHERE project_id = $1
|
|
AND ($2::text = '' OR kind = $2)
|
|
ORDER BY kind ASC, created_at DESC
|
|
`
|
|
|
|
type ListByProjectParams struct {
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
Column2 string `json:"column_2"`
|
|
}
|
|
|
|
type ListByProjectRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
EmbeddingModel *string `json:"embedding_model"`
|
|
CreatedBy pgtype.UUID `json:"created_by"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) ListByProject(ctx context.Context, arg ListByProjectParams) ([]ListByProjectRow, error) {
|
|
rows, err := q.db.Query(ctx, listByProject, arg.ProjectID, arg.Column2)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListByProjectRow
|
|
for rows.Next() {
|
|
var i ListByProjectRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Title,
|
|
&i.Body,
|
|
&i.Tags,
|
|
&i.Source,
|
|
&i.EmbeddingModel,
|
|
&i.CreatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchByKeyword = `-- name: SearchByKeyword :many
|
|
SELECT id, project_id, workspace_id, kind, title, body, tags, source,
|
|
embedding_model, created_by, created_at, updated_at
|
|
FROM project_memory
|
|
WHERE project_id = $1
|
|
AND ($2::text = '' OR kind = $2)
|
|
AND ($3::text = '' OR title ILIKE '%' || $3 || '%' OR body ILIKE '%' || $3 || '%' OR $3 = ANY(tags))
|
|
ORDER BY updated_at DESC
|
|
LIMIT $4
|
|
`
|
|
|
|
type SearchByKeywordParams struct {
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
Column2 string `json:"column_2"`
|
|
Column3 string `json:"column_3"`
|
|
Limit int32 `json:"limit"`
|
|
}
|
|
|
|
type SearchByKeywordRow struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
Kind string `json:"kind"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Tags []string `json:"tags"`
|
|
Source string `json:"source"`
|
|
EmbeddingModel *string `json:"embedding_model"`
|
|
CreatedBy pgtype.UUID `json:"created_by"`
|
|
CreatedAt pgtype.Timestamptz `json:"created_at"`
|
|
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) SearchByKeyword(ctx context.Context, arg SearchByKeywordParams) ([]SearchByKeywordRow, error) {
|
|
rows, err := q.db.Query(ctx, searchByKeyword,
|
|
arg.ProjectID,
|
|
arg.Column2,
|
|
arg.Column3,
|
|
arg.Limit,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []SearchByKeywordRow
|
|
for rows.Next() {
|
|
var i SearchByKeywordRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.Kind,
|
|
&i.Title,
|
|
&i.Body,
|
|
&i.Tags,
|
|
&i.Source,
|
|
&i.EmbeddingModel,
|
|
&i.CreatedBy,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|