Files
Memoh/internal/db/sqlc/schedule_logs.sql.go
T
Acbox bcda6f6fe6 refactor: replace Load More with Pagination across frontend and backend
- Replace all "Load More" / "Show More" buttons with Pagination components
  in model-list, bot-compaction, and bot-heartbeat views
- Convert backend log APIs (compaction, heartbeat, schedule) from
  cursor-based (before+limit) to offset+limit pagination with total_count
- Update SQL queries to use OFFSET+LIMIT and add COUNT queries
- Add shared parseOffsetLimit helper in handler_helpers.go
- Regenerate sqlc, Swagger docs, and TypeScript SDK
- Clean up unused i18n keys (loadMore, showMore, history.loadMore)
2026-03-29 18:49:30 +08:00

259 lines
7.3 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: schedule_logs.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const completeScheduleLog = `-- name: CompleteScheduleLog :one
UPDATE schedule_logs
SET status = $2,
result_text = $3,
error_message = $4,
usage = $5,
model_id = $6,
completed_at = now()
WHERE id = $1
RETURNING id, schedule_id, bot_id, session_id, status, result_text, error_message, usage, model_id, started_at, completed_at
`
type CompleteScheduleLogParams struct {
ID pgtype.UUID `json:"id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
ModelID pgtype.UUID `json:"model_id"`
}
func (q *Queries) CompleteScheduleLog(ctx context.Context, arg CompleteScheduleLogParams) (ScheduleLog, error) {
row := q.db.QueryRow(ctx, completeScheduleLog,
arg.ID,
arg.Status,
arg.ResultText,
arg.ErrorMessage,
arg.Usage,
arg.ModelID,
)
var i ScheduleLog
err := row.Scan(
&i.ID,
&i.ScheduleID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.ModelID,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const countScheduleLogsByBot = `-- name: CountScheduleLogsByBot :one
SELECT count(*) FROM schedule_logs WHERE bot_id = $1
`
func (q *Queries) CountScheduleLogsByBot(ctx context.Context, botID pgtype.UUID) (int64, error) {
row := q.db.QueryRow(ctx, countScheduleLogsByBot, botID)
var count int64
err := row.Scan(&count)
return count, err
}
const countScheduleLogsBySchedule = `-- name: CountScheduleLogsBySchedule :one
SELECT count(*) FROM schedule_logs WHERE schedule_id = $1
`
func (q *Queries) CountScheduleLogsBySchedule(ctx context.Context, scheduleID pgtype.UUID) (int64, error) {
row := q.db.QueryRow(ctx, countScheduleLogsBySchedule, scheduleID)
var count int64
err := row.Scan(&count)
return count, err
}
const createScheduleLog = `-- name: CreateScheduleLog :one
INSERT INTO schedule_logs (schedule_id, bot_id, session_id, started_at)
VALUES ($1, $2, $3::uuid, now())
RETURNING id, schedule_id, bot_id, session_id, status, result_text, error_message, usage, started_at, completed_at
`
type CreateScheduleLogParams struct {
ScheduleID pgtype.UUID `json:"schedule_id"`
BotID pgtype.UUID `json:"bot_id"`
SessionID pgtype.UUID `json:"session_id"`
}
type CreateScheduleLogRow struct {
ID pgtype.UUID `json:"id"`
ScheduleID pgtype.UUID `json:"schedule_id"`
BotID pgtype.UUID `json:"bot_id"`
SessionID pgtype.UUID `json:"session_id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
StartedAt pgtype.Timestamptz `json:"started_at"`
CompletedAt pgtype.Timestamptz `json:"completed_at"`
}
func (q *Queries) CreateScheduleLog(ctx context.Context, arg CreateScheduleLogParams) (CreateScheduleLogRow, error) {
row := q.db.QueryRow(ctx, createScheduleLog, arg.ScheduleID, arg.BotID, arg.SessionID)
var i CreateScheduleLogRow
err := row.Scan(
&i.ID,
&i.ScheduleID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const deleteScheduleLogsByBot = `-- name: DeleteScheduleLogsByBot :exec
DELETE FROM schedule_logs WHERE bot_id = $1
`
func (q *Queries) DeleteScheduleLogsByBot(ctx context.Context, botID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteScheduleLogsByBot, botID)
return err
}
const deleteScheduleLogsBySchedule = `-- name: DeleteScheduleLogsBySchedule :exec
DELETE FROM schedule_logs WHERE schedule_id = $1
`
func (q *Queries) DeleteScheduleLogsBySchedule(ctx context.Context, scheduleID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteScheduleLogsBySchedule, scheduleID)
return err
}
const listScheduleLogsByBot = `-- name: ListScheduleLogsByBot :many
SELECT id, schedule_id, bot_id, session_id, status, result_text, error_message, usage, started_at, completed_at
FROM schedule_logs
WHERE bot_id = $1
ORDER BY started_at DESC
LIMIT $2 OFFSET $3
`
type ListScheduleLogsByBotParams struct {
BotID pgtype.UUID `json:"bot_id"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type ListScheduleLogsByBotRow struct {
ID pgtype.UUID `json:"id"`
ScheduleID pgtype.UUID `json:"schedule_id"`
BotID pgtype.UUID `json:"bot_id"`
SessionID pgtype.UUID `json:"session_id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
StartedAt pgtype.Timestamptz `json:"started_at"`
CompletedAt pgtype.Timestamptz `json:"completed_at"`
}
func (q *Queries) ListScheduleLogsByBot(ctx context.Context, arg ListScheduleLogsByBotParams) ([]ListScheduleLogsByBotRow, error) {
rows, err := q.db.Query(ctx, listScheduleLogsByBot, arg.BotID, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListScheduleLogsByBotRow
for rows.Next() {
var i ListScheduleLogsByBotRow
if err := rows.Scan(
&i.ID,
&i.ScheduleID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listScheduleLogsBySchedule = `-- name: ListScheduleLogsBySchedule :many
SELECT id, schedule_id, bot_id, session_id, status, result_text, error_message, usage, started_at, completed_at
FROM schedule_logs
WHERE schedule_id = $1
ORDER BY started_at DESC
LIMIT $2 OFFSET $3
`
type ListScheduleLogsByScheduleParams struct {
ScheduleID pgtype.UUID `json:"schedule_id"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type ListScheduleLogsByScheduleRow struct {
ID pgtype.UUID `json:"id"`
ScheduleID pgtype.UUID `json:"schedule_id"`
BotID pgtype.UUID `json:"bot_id"`
SessionID pgtype.UUID `json:"session_id"`
Status string `json:"status"`
ResultText string `json:"result_text"`
ErrorMessage string `json:"error_message"`
Usage []byte `json:"usage"`
StartedAt pgtype.Timestamptz `json:"started_at"`
CompletedAt pgtype.Timestamptz `json:"completed_at"`
}
func (q *Queries) ListScheduleLogsBySchedule(ctx context.Context, arg ListScheduleLogsByScheduleParams) ([]ListScheduleLogsByScheduleRow, error) {
rows, err := q.db.Query(ctx, listScheduleLogsBySchedule, arg.ScheduleID, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListScheduleLogsByScheduleRow
for rows.Next() {
var i ListScheduleLogsByScheduleRow
if err := rows.Scan(
&i.ID,
&i.ScheduleID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}