Files
Memoh/internal/db/sqlc/heartbeat_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

175 lines
4.7 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.30.0
// source: heartbeat_logs.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const completeHeartbeatLog = `-- name: CompleteHeartbeatLog :one
UPDATE bot_heartbeat_logs
SET status = $2,
result_text = $3,
error_message = $4,
usage = $5,
model_id = $6,
completed_at = now()
WHERE id = $1
RETURNING id, bot_id, session_id, status, result_text, error_message, usage, model_id, started_at, completed_at
`
type CompleteHeartbeatLogParams 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) CompleteHeartbeatLog(ctx context.Context, arg CompleteHeartbeatLogParams) (BotHeartbeatLog, error) {
row := q.db.QueryRow(ctx, completeHeartbeatLog,
arg.ID,
arg.Status,
arg.ResultText,
arg.ErrorMessage,
arg.Usage,
arg.ModelID,
)
var i BotHeartbeatLog
err := row.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.ModelID,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const countHeartbeatLogsByBot = `-- name: CountHeartbeatLogsByBot :one
SELECT count(*) FROM bot_heartbeat_logs WHERE bot_id = $1
`
func (q *Queries) CountHeartbeatLogsByBot(ctx context.Context, botID pgtype.UUID) (int64, error) {
row := q.db.QueryRow(ctx, countHeartbeatLogsByBot, botID)
var count int64
err := row.Scan(&count)
return count, err
}
const createHeartbeatLog = `-- name: CreateHeartbeatLog :one
INSERT INTO bot_heartbeat_logs (bot_id, session_id, started_at)
VALUES ($1, $2::uuid, now())
RETURNING id, bot_id, session_id, status, result_text, error_message, usage, started_at, completed_at
`
type CreateHeartbeatLogParams struct {
BotID pgtype.UUID `json:"bot_id"`
SessionID pgtype.UUID `json:"session_id"`
}
type CreateHeartbeatLogRow struct {
ID pgtype.UUID `json:"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) CreateHeartbeatLog(ctx context.Context, arg CreateHeartbeatLogParams) (CreateHeartbeatLogRow, error) {
row := q.db.QueryRow(ctx, createHeartbeatLog, arg.BotID, arg.SessionID)
var i CreateHeartbeatLogRow
err := row.Scan(
&i.ID,
&i.BotID,
&i.SessionID,
&i.Status,
&i.ResultText,
&i.ErrorMessage,
&i.Usage,
&i.StartedAt,
&i.CompletedAt,
)
return i, err
}
const deleteHeartbeatLogsByBot = `-- name: DeleteHeartbeatLogsByBot :exec
DELETE FROM bot_heartbeat_logs WHERE bot_id = $1
`
func (q *Queries) DeleteHeartbeatLogsByBot(ctx context.Context, botID pgtype.UUID) error {
_, err := q.db.Exec(ctx, deleteHeartbeatLogsByBot, botID)
return err
}
const listHeartbeatLogsByBot = `-- name: ListHeartbeatLogsByBot :many
SELECT id, bot_id, session_id, status, result_text, error_message, usage, started_at, completed_at
FROM bot_heartbeat_logs
WHERE bot_id = $1
ORDER BY started_at DESC
LIMIT $2 OFFSET $3
`
type ListHeartbeatLogsByBotParams struct {
BotID pgtype.UUID `json:"bot_id"`
Limit int32 `json:"limit"`
Offset int32 `json:"offset"`
}
type ListHeartbeatLogsByBotRow struct {
ID pgtype.UUID `json:"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) ListHeartbeatLogsByBot(ctx context.Context, arg ListHeartbeatLogsByBotParams) ([]ListHeartbeatLogsByBotRow, error) {
rows, err := q.db.Query(ctx, listHeartbeatLogsByBot, arg.BotID, arg.Limit, arg.Offset)
if err != nil {
return nil, err
}
defer rows.Close()
var items []ListHeartbeatLogsByBotRow
for rows.Next() {
var i ListHeartbeatLogsByBotRow
if err := rows.Scan(
&i.ID,
&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
}