You've already forked agentic-coding-workflow
190 lines
5.1 KiB
Go
190 lines
5.1 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.31.1
|
|
// source: conversations.sql
|
|
|
|
package chatsqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const getConversation = `-- name: GetConversation :one
|
|
SELECT id, user_id, project_id, workspace_id, issue_id, model_id, system_prompt, title, title_generated_at, created_at, updated_at, deleted_at, requirement_id FROM conversations WHERE id = $1 AND deleted_at IS NULL
|
|
`
|
|
|
|
func (q *Queries) GetConversation(ctx context.Context, id pgtype.UUID) (Conversation, error) {
|
|
row := q.db.QueryRow(ctx, getConversation, id)
|
|
var i Conversation
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.IssueID,
|
|
&i.ModelID,
|
|
&i.SystemPrompt,
|
|
&i.Title,
|
|
&i.TitleGeneratedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.RequirementID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertConversation = `-- name: InsertConversation :one
|
|
INSERT INTO conversations (id, user_id, project_id, workspace_id, issue_id, model_id, system_prompt, title, requirement_id)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
RETURNING id, user_id, project_id, workspace_id, issue_id, model_id, system_prompt, title, title_generated_at, created_at, updated_at, deleted_at, requirement_id
|
|
`
|
|
|
|
type InsertConversationParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
ProjectID pgtype.UUID `json:"project_id"`
|
|
WorkspaceID pgtype.UUID `json:"workspace_id"`
|
|
IssueID pgtype.UUID `json:"issue_id"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
SystemPrompt string `json:"system_prompt"`
|
|
Title *string `json:"title"`
|
|
RequirementID pgtype.UUID `json:"requirement_id"`
|
|
}
|
|
|
|
func (q *Queries) InsertConversation(ctx context.Context, arg InsertConversationParams) (Conversation, error) {
|
|
row := q.db.QueryRow(ctx, insertConversation,
|
|
arg.ID,
|
|
arg.UserID,
|
|
arg.ProjectID,
|
|
arg.WorkspaceID,
|
|
arg.IssueID,
|
|
arg.ModelID,
|
|
arg.SystemPrompt,
|
|
arg.Title,
|
|
arg.RequirementID,
|
|
)
|
|
var i Conversation
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.IssueID,
|
|
&i.ModelID,
|
|
&i.SystemPrompt,
|
|
&i.Title,
|
|
&i.TitleGeneratedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.RequirementID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listConversationsByUser = `-- name: ListConversationsByUser :many
|
|
SELECT id, user_id, project_id, workspace_id, issue_id, model_id, system_prompt, title, title_generated_at, created_at, updated_at, deleted_at, requirement_id FROM conversations
|
|
WHERE user_id = $1 AND deleted_at IS NULL
|
|
AND ($2::uuid IS NULL OR project_id = $2)
|
|
AND ($3::uuid IS NULL OR workspace_id = $3)
|
|
AND ($4::uuid IS NULL OR issue_id = $4)
|
|
AND ($5::uuid IS NULL OR requirement_id = $5)
|
|
AND ($6::text = '' OR title ILIKE '%' || $6 || '%')
|
|
ORDER BY updated_at DESC
|
|
LIMIT $7
|
|
`
|
|
|
|
type ListConversationsByUserParams struct {
|
|
UserID pgtype.UUID `json:"user_id"`
|
|
Column2 pgtype.UUID `json:"column_2"`
|
|
Column3 pgtype.UUID `json:"column_3"`
|
|
Column4 pgtype.UUID `json:"column_4"`
|
|
Column5 pgtype.UUID `json:"column_5"`
|
|
Column6 string `json:"column_6"`
|
|
Limit int32 `json:"limit"`
|
|
}
|
|
|
|
func (q *Queries) ListConversationsByUser(ctx context.Context, arg ListConversationsByUserParams) ([]Conversation, error) {
|
|
rows, err := q.db.Query(ctx, listConversationsByUser,
|
|
arg.UserID,
|
|
arg.Column2,
|
|
arg.Column3,
|
|
arg.Column4,
|
|
arg.Column5,
|
|
arg.Column6,
|
|
arg.Limit,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Conversation
|
|
for rows.Next() {
|
|
var i Conversation
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.UserID,
|
|
&i.ProjectID,
|
|
&i.WorkspaceID,
|
|
&i.IssueID,
|
|
&i.ModelID,
|
|
&i.SystemPrompt,
|
|
&i.Title,
|
|
&i.TitleGeneratedAt,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.RequirementID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const setConversationTitleManual = `-- name: SetConversationTitleManual :exec
|
|
UPDATE conversations SET title = $2, updated_at = NOW() WHERE id = $1
|
|
`
|
|
|
|
type SetConversationTitleManualParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Title *string `json:"title"`
|
|
}
|
|
|
|
func (q *Queries) SetConversationTitleManual(ctx context.Context, arg SetConversationTitleManualParams) error {
|
|
_, err := q.db.Exec(ctx, setConversationTitleManual, arg.ID, arg.Title)
|
|
return err
|
|
}
|
|
|
|
const softDeleteConversation = `-- name: SoftDeleteConversation :exec
|
|
UPDATE conversations SET deleted_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1 AND deleted_at IS NULL
|
|
`
|
|
|
|
func (q *Queries) SoftDeleteConversation(ctx context.Context, id pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, softDeleteConversation, id)
|
|
return err
|
|
}
|
|
|
|
const updateConversationTitle = `-- name: UpdateConversationTitle :exec
|
|
UPDATE conversations SET title = $2, title_generated_at = NOW(), updated_at = NOW()
|
|
WHERE id = $1
|
|
`
|
|
|
|
type UpdateConversationTitleParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Title *string `json:"title"`
|
|
}
|
|
|
|
func (q *Queries) UpdateConversationTitle(ctx context.Context, arg UpdateConversationTitleParams) error {
|
|
_, err := q.db.Exec(ctx, updateConversationTitle, arg.ID, arg.Title)
|
|
return err
|
|
}
|