mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +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:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
||||
@@ -46,3 +48,19 @@ func AuthorizeBotAccess(ctx context.Context, botService *bots.Service, accountSe
|
||||
}
|
||||
return bot, nil
|
||||
}
|
||||
|
||||
// parseOffsetLimit extracts limit and offset query parameters with defaults.
|
||||
func parseOffsetLimit(c echo.Context) (limit, offset int) {
|
||||
limit = 50
|
||||
if raw := strings.TrimSpace(c.QueryParam("limit")); raw != "" {
|
||||
if v, err := strconv.Atoi(raw); err == nil && v > 0 {
|
||||
limit = v
|
||||
}
|
||||
}
|
||||
if raw := strings.TrimSpace(c.QueryParam("offset")); raw != "" {
|
||||
if v, err := strconv.Atoi(raw); err == nil && v >= 0 {
|
||||
offset = v
|
||||
}
|
||||
}
|
||||
return limit, offset
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user