mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
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)
This commit is contained in:
@@ -61,6 +61,17 @@ func (q *Queries) CompleteCompactionLog(ctx context.Context, arg CompleteCompact
|
||||
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)
|
||||
@@ -129,19 +140,18 @@ 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
|
||||
AND ($2::timestamptz IS NULL OR started_at < $2)
|
||||
ORDER BY started_at DESC
|
||||
LIMIT $3
|
||||
LIMIT $2 OFFSET $3
|
||||
`
|
||||
|
||||
type ListCompactionLogsByBotParams struct {
|
||||
BotID pgtype.UUID `json:"bot_id"`
|
||||
Column2 pgtype.Timestamptz `json:"column_2"`
|
||||
Limit int32 `json:"limit"`
|
||||
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.Column2, arg.Limit)
|
||||
rows, err := q.db.Query(ctx, listCompactionLogsByBot, arg.BotID, arg.Limit, arg.Offset)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user