Skip to content

feat: add paginated kv list for admin#253

Merged
cf-pages merged 1 commit intomainfrom
codex/optimize-image-loading-for-kvapi
Aug 15, 2025
Merged

feat: add paginated kv list for admin#253
cf-pages merged 1 commit intomainfrom
codex/optimize-image-loading-for-kvapi

Conversation

@cf-pages
Copy link
Owner

Summary

  • paginate KV listing with cursor and limit support
  • add 'load more' functionality to admin interfaces to avoid loading all records at once
  • cover pagination logic with unit tests

Testing

  • npm test
  • npm run ci-test

https://chatgpt.com/codex/tasks/task_b_6890775a943c832a8b17a042fa39e0ec

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 11, 2025

Deploying tpic with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2fcb35a
Status:🚫  Deploy failed.

View logs

@cf-pages cf-pages merged commit b9507b6 into main Aug 15, 2025
1 of 2 checks passed
@cf-pages cf-pages requested a review from Copilot August 15, 2025 02:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds pagination functionality to the KV list API for admin interfaces to improve performance when managing large numbers of files. Instead of loading all records at once, the system now supports cursor-based pagination with configurable limits.

Key changes:

  • Implemented cursor-based pagination in the KV list API with limit and cursor query parameters
  • Added "load more" functionality to all admin interfaces (admin.html, admin-waterfall.html, admin-imgtc.html)
  • Added comprehensive unit tests for pagination logic

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
functions/api/manage/list.js Replaced simple list() call with paginated version supporting limit and cursor parameters
test/pagination.test.js Added unit tests covering pagination scenarios including cursor handling and completion detection
test/test.js Removed old image loading test (unrelated to pagination feature)
admin.html Added load more button and cursor tracking for paginated data loading
admin-waterfall.html Refactored to use pagination with load more functionality
admin-imgtc.html Updated file list loading to support pagination with load more button

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$.ajax({
url: cursor
? "./api/manage/list?cursor=" + encodeURIComponent(cursor)
: "./api/manage/list?limit=100",
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded limit value '100' is duplicated across multiple files. Consider defining this as a constant to maintain consistency and make it easier to change.

Copilot uses AI. Check for mistakes.
const opts = { method: 'GET', credentials: 'include' };
const url = this.nextCursor
? `./api/manage/list?cursor=${encodeURIComponent(this.nextCursor)}`
: `./api/manage/list?limit=100`;
Copy link

Copilot AI Aug 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded limit value '100' is duplicated across multiple files. Consider defining this as a constant to maintain consistency and make it easier to change.

Suggested change
: `./api/manage/list?limit=100`;
: `./api/manage/list?limit=${LIST_LIMIT}`;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants