Skip to content

Help-request progress (currentAmount) is never returned by the posts list API — feed shows $0 raised / 0% funded #355

Description

@3m1n3nc3

Description

The GET /api/posts list query only includes user and _count: { entries, interactions, comments }. It never aggregates helpContributions.amount nor returns a currentAmount field, and lib/map-api-post.ts does not derive one. As a result post.currentAmount is undefined everywhere the feed renders it, so help-request cards show "$undefined / $0 raised" and 0% progress, and ContributionForm's "remaining" math is wrong. Only the dedicated per-post contributions endpoint computes totalRaised.

More info

  • File: app/app/api/posts/route.ts (GET include, approx. lines 271-286)
  • File: app/lib/map-api-post.ts
  • File: app/components/post-card.tsx (approx. lines 350-365), app/components/contribution-form.tsx
  • Aggregate helpContributions sums in the posts query (or via _sum) and map to currentAmount in mapApiPostToClientPost.
  • Add a test asserting a request post with contributions reports the correct currentAmount and progress percentage from the list endpoint.

Metadata

Metadata

Assignees

Labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions