You've already forked agentic-coding-workflow
feat(chat): sqlc queries for conversations/messages/attachments/templates/endpoints/models/usage
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
// 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 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,
|
||||
)
|
||||
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)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
|
||||
RETURNING id, user_id, project_id, workspace_id, issue_id, model_id, system_prompt, title, title_generated_at, created_at, updated_at, deleted_at
|
||||
`
|
||||
|
||||
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"`
|
||||
}
|
||||
|
||||
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,
|
||||
)
|
||||
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,
|
||||
)
|
||||
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 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::text = '' OR title ILIKE '%' || $5 || '%')
|
||||
ORDER BY updated_at DESC
|
||||
LIMIT $6
|
||||
`
|
||||
|
||||
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 string `json:"column_5"`
|
||||
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.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,
|
||||
); 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
|
||||
}
|
||||
Reference in New Issue
Block a user