import asyncioimport httpxasync def fetch_all_issues(ws_id: str, token: str): """Fetch all issues using pagination.""" base = "http://localhost:8000/api/v1" headers = {"Authorization": f"Bearer {token}"} all_issues = [] offset = 0 page_size = 50 async with httpx.AsyncClient() as client: while True: resp = await client.get( f"{base}/workspaces/{ws_id}/issues/", params={"limit": page_size, "offset": offset}, headers=headers ) page = resp.json() if not page: break # No more results all_issues.extend(page) if len(page) < page_size: break # Last page offset += page_size return all_issuesasync def main(): issues = await fetch_all_issues("your-ws-id", "your-token") print(f"Total issues: {len(issues)}")asyncio.run(main())
async function fetchAllIssues(wsId, token) { const base = "http://localhost:8000/api/v1"; const headers = { Authorization: `Bearer ${token}` }; const allIssues = []; let offset = 0; const pageSize = 50; while (true) { const response = await fetch( `${base}/workspaces/${wsId}/issues/?limit=${pageSize}&offset=${offset}`, { headers } ); const page = await response.json(); if (!page.length) break; // No more results allIssues.push(...page); if (page.length < pageSize) break; // Last page offset += pageSize; } return allIssues;}// Usageconst issues = await fetchAllIssues("your-ws-id", "your-token");console.log(`Total issues: ${issues.length}`);
#!/bin/bashTOKEN="your-jwt-token"WS_ID="workspace-id"BASE_URL="http://localhost:8000/api/v1"OFFSET=0PAGE_SIZE=50ALL_ISSUES=()while true; do RESPONSE=$(curl -s "${BASE_URL}/workspaces/${WS_ID}/issues/?limit=${PAGE_SIZE}&offset=${OFFSET}" \ -H "Authorization: Bearer ${TOKEN}") # Check if response is empty array if [[ "$RESPONSE" == "[]" ]]; then break fi # Count items in response ITEM_COUNT=$(echo "$RESPONSE" | jq '. | length') if [[ $ITEM_COUNT -eq 0 ]]; then break fi echo "Fetched $ITEM_COUNT items (offset: $OFFSET)" # Break if less than page size (last page) if [[ $ITEM_COUNT -lt $PAGE_SIZE ]]; then break fi OFFSET=$((OFFSET + PAGE_SIZE))doneecho "Pagination complete"
# Test boundary conditionspytest tests/test_new_gaps.py::TestPagination -v# Test API integrationpytest tests/test_new_api_integration.py::TestPaginationAPI -v# Manual testing with curlcurl -s "http://localhost:8000/api/v1/workspaces/test/issues/?limit=1&offset=0"curl -s "http://localhost:8000/api/v1/workspaces/test/issues/?limit=999&offset=0" # Should limit to 200