Skip to content

Refactor Labor Hub post fetching#4746

Merged
cemreinanc merged 2 commits into
mainfrom
hotfix/labor-hub-cache
May 19, 2026
Merged

Refactor Labor Hub post fetching#4746
cemreinanc merged 2 commits into
mainfrom
hotfix/labor-hub-cache

Conversation

@cemreinanc
Copy link
Copy Markdown
Contributor

@cemreinanc cemreinanc commented May 19, 2026

Summary by CodeRabbit

  • Refactor
    • Optimized internal data fetching architecture for Labor Hub by consolidating post retrieval through new helper functions.
    • Replaced hardcoded configuration values with managed constants for improved maintainability.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@cemreinanc has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 23 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 18acf70a-e8ff-4d50-9571-6b9680c79750

📥 Commits

Reviewing files that changed from the base of the PR and between b7ac1a5 and 53e1566.

📒 Files selected for processing (1)
  • front_end/src/app/(main)/labor-hub/page.tsx
📝 Walkthrough

Walkthrough

This PR consolidates Labor Hub post data fetching into a centralized helper module. Direct ServerPostsApi calls across question cards, data helpers, and pages are replaced with new fetchLaborHubPost and fetchLaborHubPostsByIds functions. Hardcoded post IDs are replaced with named constants from LABOR_HUB_POST_IDS. The API signature for getPostsWithCPAnonymous is expanded to accept additional fetch parameters.

Changes

Labor Hub Data Layer Consolidation

Layer / File(s) Summary
Foundation: Helper module and API signature
front_end/src/app/(main)/labor-hub/helpers/labor_hub_posts.ts, front_end/src/services/api/posts/posts.shared.ts
Introduces labor_hub_posts.ts with exported post ID constants (LABOR_HUB_POST_IDS, LABOR_HUB_ALL_POST_IDS) and cached fetch helpers (fetchLaborHubPost, fetchLaborHubPostsByIds). Expands getPostsWithCPAnonymous signature to accept PostFetchParams.
Question card components migration
front_end/src/app/(main)/labor-hub/components/question_cards/flippable_chart_timeline_card.tsx, multi_question_data.ts, question.tsx
Updates three question card modules to use the new helpers instead of direct ServerPostsApi calls. Preserves error handling and placeholder rendering when data is unavailable.
Data helper modules migration
front_end/src/app/(main)/labor-hub/helpers/fetch_jobs_data.ts, fetch_key_insights_data.ts
Replaces ServerPostsApi calls with the new helpers and updates hardcoded post IDs to use LABOR_HUB_POST_IDS constants. Maintains existing data transformation and fallback logic.
Page and section components wiring
front_end/src/app/(main)/labor-hub/page.tsx, sections/activity_monitor.tsx, sections/research.tsx
Replaces all hardcoded numeric post IDs with LABOR_HUB_POST_IDS constants across Wages, Family Resources, Graduates, Economy, State, Activity Monitor, and Research sections. No logic or layout changes beyond identifier substitutions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Metaculus/metaculus#4478: The PR's update to PostsApi.getPostsWithCPAnonymous to support PostFetchParams aligns with prior work introducing fetch options for CP-history retrieval.

Suggested reviewers

  • ncarazon
  • hlbmtc

Poem

🐰 Constants now guide where the posts shall be found,
No magic numbers scattered all around!
Helpers fetch the data, cached and true,
Labor Hub's data layer—shiny and new. ✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a new local helper module for Labor Hub post fetching and refactoring multiple components to use it instead of direct API calls.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/labor-hub-cache

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

Cleanup: Preview Environment Removed

The preview environment for this PR has been destroyed.

Resource Status
🌐 Preview App Deleted
🗄️ PostgreSQL Branch Deleted
⚡ Redis Database Deleted
🔧 GitHub Deployments Removed
📦 Docker Image Retained (auto-cleanup via GHCR policies)

Cleanup triggered by PR close at 2026-05-19T20:09:20Z

@cemreinanc cemreinanc merged commit 6744332 into main May 19, 2026
16 checks passed
@cemreinanc cemreinanc deleted the hotfix/labor-hub-cache branch May 19, 2026 20:09
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.

2 participants