Skip to content

updated backend static - #4

Merged
SCGR-1 merged 2 commits into
mainfrom
Oct_4
Nov 1, 2025
Merged

updated backend static#4
SCGR-1 merged 2 commits into
mainfrom
Oct_4

Conversation

@SCGR-1

@SCGR-1 SCGR-1 commented Nov 1, 2025

Copy link
Copy Markdown
Owner

No description provided.

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

const fetchCaptions = useCallback(() => {
setIsLoadingContent(true);
setFetchError(null);
// Build query parameters for server-side filtering and pagination
const params = new URLSearchParams({
page: currentPage.toString(),
limit: itemsPerPage.toString(),
include_count: 'true'
});
if (search) params.append('search', search);
if (srcFilter) params.append('source', srcFilter);
if (catFilter) params.append('event_type', catFilter);
if (regionFilter) params.append('region', regionFilter);
if (countryFilter) params.append('country', countryFilter);
if (imageTypeFilter) params.append('image_type', imageTypeFilter);
if (uploadTypeFilter) params.append('upload_type', uploadTypeFilter);
if (showReferenceExamples) params.append('starred_only', 'true');
fetch(`/api/images/grouped?${params.toString()}`)
.then(r => {
if (!r.ok) {
throw new Error(`Failed to fetch images: ${r.status} ${r.statusText}`);
}
return r.json();
})
.then(data => {
console.log('ExplorePage: Fetched captions:', data);
if (data.items && typeof data.total_count === 'number') {
setCaptions(data.items);
setTotalItems(data.total_count);
setTotalPages(Math.ceil(data.total_count / itemsPerPage));
} else if (Array.isArray(data)) {
setCaptions(data);
} else {
throw new Error('Unexpected response format');
}
setFetchError(null);
})
.catch(error => {
console.error('ExplorePage: Error fetching captions:', error);
setFetchError(error instanceof Error ? error.message : 'Failed to load images. Please try again later.');
setCaptions([]);
setTotalItems(0);
setTotalPages(0);
})
.finally(() => {
setIsLoadingContent(false);
});
}, [currentPage, search, srcFilter, catFilter, regionFilter, countryFilter, imageTypeFilter, uploadTypeFilter, showReferenceExamples, itemsPerPage]);
// Fetch data when component mounts or filters change
useEffect(() => {
fetchCaptions();
}, [fetchCaptions]);
// Reset to first page when filters change (but not when currentPage changes)
useEffect(() => {
setCurrentPage(1);
}, [search, srcFilter, catFilter, regionFilter, countryFilter, imageTypeFilter, uploadTypeFilter, showReferenceExamples]);

P1 Badge Paginated list no longer updates total item counts

The new fetch logic assumes /api/images/grouped returns an object with items and total_count and the separate /grouped/count request has been removed. The backend in this repository still exposes /api/images/grouped as a list response and offers counts through /grouped/count, so totalItems and totalPages stay at their initial value of 0 when data is returned. Because Paginator hides itself when totalPages <= 1, users lose the ability to navigate beyond the first page and the "X of Y" summary always shows Y = 0 even when results exist. This happens consistently with the current backend API.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SCGR-1
SCGR-1 merged commit f674a31 into main Nov 1, 2025
3 checks passed
@SCGR-1
SCGR-1 deleted the Oct_4 branch March 6, 2026 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant