mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
bcda6f6fe6
- 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)
223 lines
5.6 KiB
Go
223 lines
5.6 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.30.0
|
|
// source: compaction_logs.sql
|
|
|
|
package sqlc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const completeCompactionLog = `-- name: CompleteCompactionLog :one
|
|
UPDATE bot_history_message_compacts
|
|
SET status = $2,
|
|
summary = $3,
|
|
message_count = $4,
|
|
error_message = $5,
|
|
usage = $6,
|
|
model_id = $7,
|
|
completed_at = now()
|
|
WHERE id = $1
|
|
RETURNING id, bot_id, session_id, status, summary, message_count, error_message, usage, model_id, started_at, completed_at
|
|
`
|
|
|
|
type CompleteCompactionLogParams struct {
|
|
ID pgtype.UUID `json:"id"`
|
|
Status string `json:"status"`
|
|
Summary string `json:"summary"`
|
|
MessageCount int32 `json:"message_count"`
|
|
ErrorMessage string `json:"error_message"`
|
|
Usage []byte `json:"usage"`
|
|
ModelID pgtype.UUID `json:"model_id"`
|
|
}
|
|
|
|
func (q *Queries) CompleteCompactionLog(ctx context.Context, arg CompleteCompactionLogParams) (BotHistoryMessageCompact, error) {
|
|
row := q.db.QueryRow(ctx, completeCompactionLog,
|
|
arg.ID,
|
|
arg.Status,
|
|
arg.Summary,
|
|
arg.MessageCount,
|
|
arg.ErrorMessage,
|
|
arg.Usage,
|
|
arg.ModelID,
|
|
)
|
|
var i BotHistoryMessageCompact
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.SessionID,
|
|
&i.Status,
|
|
&i.Summary,
|
|
&i.MessageCount,
|
|
&i.ErrorMessage,
|
|
&i.Usage,
|
|
&i.ModelID,
|
|
&i.StartedAt,
|
|
&i.CompletedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const countCompactionLogsByBot = `-- name: CountCompactionLogsByBot :one
|
|
SELECT count(*) FROM bot_history_message_compacts WHERE bot_id = $1
|
|
`
|
|
|
|
func (q *Queries) CountCompactionLogsByBot(ctx context.Context, botID pgtype.UUID) (int64, error) {
|
|
row := q.db.QueryRow(ctx, countCompactionLogsByBot, botID)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createCompactionLog = `-- name: CreateCompactionLog :one
|
|
INSERT INTO bot_history_message_compacts (bot_id, session_id)
|
|
VALUES ($1, $2)
|
|
RETURNING id, bot_id, session_id, status, summary, message_count, error_message, usage, model_id, started_at, completed_at
|
|
`
|
|
|
|
type CreateCompactionLogParams struct {
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
SessionID pgtype.UUID `json:"session_id"`
|
|
}
|
|
|
|
func (q *Queries) CreateCompactionLog(ctx context.Context, arg CreateCompactionLogParams) (BotHistoryMessageCompact, error) {
|
|
row := q.db.QueryRow(ctx, createCompactionLog, arg.BotID, arg.SessionID)
|
|
var i BotHistoryMessageCompact
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.SessionID,
|
|
&i.Status,
|
|
&i.Summary,
|
|
&i.MessageCount,
|
|
&i.ErrorMessage,
|
|
&i.Usage,
|
|
&i.ModelID,
|
|
&i.StartedAt,
|
|
&i.CompletedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const deleteCompactionLogsByBot = `-- name: DeleteCompactionLogsByBot :exec
|
|
DELETE FROM bot_history_message_compacts WHERE bot_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCompactionLogsByBot(ctx context.Context, botID pgtype.UUID) error {
|
|
_, err := q.db.Exec(ctx, deleteCompactionLogsByBot, botID)
|
|
return err
|
|
}
|
|
|
|
const getCompactionLogByID = `-- name: GetCompactionLogByID :one
|
|
SELECT id, bot_id, session_id, status, summary, message_count, error_message, usage, model_id, started_at, completed_at
|
|
FROM bot_history_message_compacts
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetCompactionLogByID(ctx context.Context, id pgtype.UUID) (BotHistoryMessageCompact, error) {
|
|
row := q.db.QueryRow(ctx, getCompactionLogByID, id)
|
|
var i BotHistoryMessageCompact
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.SessionID,
|
|
&i.Status,
|
|
&i.Summary,
|
|
&i.MessageCount,
|
|
&i.ErrorMessage,
|
|
&i.Usage,
|
|
&i.ModelID,
|
|
&i.StartedAt,
|
|
&i.CompletedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listCompactionLogsByBot = `-- name: ListCompactionLogsByBot :many
|
|
SELECT id, bot_id, session_id, status, summary, message_count, error_message, usage, model_id, started_at, completed_at
|
|
FROM bot_history_message_compacts
|
|
WHERE bot_id = $1
|
|
ORDER BY started_at DESC
|
|
LIMIT $2 OFFSET $3
|
|
`
|
|
|
|
type ListCompactionLogsByBotParams struct {
|
|
BotID pgtype.UUID `json:"bot_id"`
|
|
Limit int32 `json:"limit"`
|
|
Offset int32 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListCompactionLogsByBot(ctx context.Context, arg ListCompactionLogsByBotParams) ([]BotHistoryMessageCompact, error) {
|
|
rows, err := q.db.Query(ctx, listCompactionLogsByBot, arg.BotID, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []BotHistoryMessageCompact
|
|
for rows.Next() {
|
|
var i BotHistoryMessageCompact
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.SessionID,
|
|
&i.Status,
|
|
&i.Summary,
|
|
&i.MessageCount,
|
|
&i.ErrorMessage,
|
|
&i.Usage,
|
|
&i.ModelID,
|
|
&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 listCompactionLogsBySession = `-- name: ListCompactionLogsBySession :many
|
|
SELECT id, bot_id, session_id, status, summary, message_count, error_message, usage, model_id, started_at, completed_at
|
|
FROM bot_history_message_compacts
|
|
WHERE session_id = $1
|
|
ORDER BY started_at ASC
|
|
`
|
|
|
|
func (q *Queries) ListCompactionLogsBySession(ctx context.Context, sessionID pgtype.UUID) ([]BotHistoryMessageCompact, error) {
|
|
rows, err := q.db.Query(ctx, listCompactionLogsBySession, sessionID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []BotHistoryMessageCompact
|
|
for rows.Next() {
|
|
var i BotHistoryMessageCompact
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.BotID,
|
|
&i.SessionID,
|
|
&i.Status,
|
|
&i.Summary,
|
|
&i.MessageCount,
|
|
&i.ErrorMessage,
|
|
&i.Usage,
|
|
&i.ModelID,
|
|
&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
|
|
}
|