Skip to content

fix(home): Make product and contributor count fetching logic more robust#1286

Merged
VaiTon merged 1 commit intomainfrom
fix/500-main-page
Apr 2, 2026
Merged

fix(home): Make product and contributor count fetching logic more robust#1286
VaiTon merged 1 commit intomainfrom
fix/500-main-page

Conversation

@VaiTon
Copy link
Copy Markdown
Member

@VaiTon VaiTon commented Apr 2, 2026

Summary by CodeRabbit

  • Improvements
    • Added loading placeholders that display while product and contributor counts are being fetched, providing visual feedback during data loading.
    • Enhanced error handling for data fetching with fallback display values when requests fail.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer Ready Ready Preview, Comment Apr 2, 2026 1:23pm

@VaiTon VaiTon linked an issue Apr 2, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

A new utility function fetchRequired is added for validated API fetching. The homepage data loading is refactored to return unresolved promises from the server and render with Svelte await blocks to display loading states and handle errors.

Changes

Cohort / File(s) Summary
New Fetch Utility
src/lib/promises.ts
Added fetchRequired function that wraps fetch with credential handling, validates HTTP response status, and parses JSON with error reporting on failure.
Server-side Data Loading
src/routes/+page.ts
Modified product count fetching to use fetchRequired with response validation; switched contributor count to use createProductsApi client; updated load function to return unresolved promises instead of awaited values.
Client-side Rendering
src/routes/+page.svelte
Replaced synchronous data display with Svelte {#await} blocks; added skeleton loading placeholders and error fallback rendering (--) for both product and contributor counts.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client / Browser
    participant Server as Page.ts Load
    participant FetchLib as fetchRequired
    participant API as API Server

    Client->>Server: Request homepage
    Server->>Server: Call load()
    Server->>FetchLib: fetchRequired(fetch, productCountURL)
    Server->>FetchLib: createProductsApi().getFacet('contributors')
    
    note over Server: Return unresolved promises
    Server-->>Client: Page data with promises
    
    par Product Count Fetch
        FetchLib->>API: GET productCount.json
        API-->>FetchLib: Response + status
        FetchLib->>FetchLib: Validate ok + format
        FetchLib-->>Client: Resolved count or error
    and Contributor Count Fetch
        FetchLib->>API: GET contributors facet
        API-->>FetchLib: Response + data
        FetchLib-->>Client: Resolved count or error
    end
    
    Client->>Client: Render await blocks
    activate Client
        Client->>Client: Show skeleton (pending)
        Client->>Client: Show CountUp (resolved)
        Client->>Client: Show -- (rejected)
    deactivate Client
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit's tail for async delight,
Promises dance in the pale moonlight,
Loading skeletons skip and bound,
While data fetches all around—
No more waiting, just let it flow! 🌙✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided; the author did not fill in any of the required template sections including description, related issues, or self-review checklist. Provide a detailed description of changes, link to any related issues using fixing keywords, and complete the self-review checklist as specified in the template.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: improving robustness of product and contributor count fetching logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/500-main-page

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@VaiTon VaiTon merged commit 4a062c9 into main Apr 2, 2026
15 of 16 checks passed
@VaiTon VaiTon deleted the fix/500-main-page branch April 2, 2026 13:32
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OFF Explorer - Primetime ! Apr 2, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 16, 2026

Issues attributed to commits in this pull request

This pull request was merged and Sentry observed the following issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Main website crash with 500 (Internal Error)

1 participant