Query & return multiple posts
Problem
Front ends that build their own lists (e.g. peakd's "top viewed") fetch many posts by author/permlink with one bridge.get_post per post (Promise.all). There is no batch call in bridge format. database_api.find_comments batches, but returns database-format objects.
Fix
Add bridge.get_posts:
- params:
posts: array of[author, permlink]pairs, 1–100;observer(optional);top_votes(0–10, default 0, as in #348 (closed)).
- result: an array of the same length and order as
posts. Each element is the post in the vote-free*_v2shape from #348 (closed): noactive_votes, withobserver_voteand optionaltop_votes. A post that doesn't exist (or is deleted) isnullin its position, so clients can map results back.
- New
postgrest/bridge_api/bridge_api_get_posts.sql. Validate thepostsshape (array of 2-string arrays; each author valid, each permlink valid; 1–100 entries) with the existing validators. Resolve ids in one query. Build each object withcreate_bridge_post_object(…, _votes_mode => 1, _top_votes => …)as the*_v2endpoints do. - Register it in
postgrest/utilities/get_api_method.sql(get_bridge_method) and inpostgrest/load_order.sql(#351 (closed)'s manifest). - Document it next to the
*_v2calls indocs/bridge-votes.md.
Acceptance
- Tavern patterns:
- a positive pattern requesting posts that existing
get_post_v2patterns already cover. The expected output is the array of those patterns' results, in request order, derivable without a data run; - one request including a nonexistent post, which returns
nullin that position; - negative patterns for 0 entries, 101 entries, a malformed pair, and
top_votes: 11.
- a positive pattern requesting posts that existing
- AIDEV's install step and smoke pass.
Original description (rewritten 2026-10-09 into an implementation spec for an AIDEV workflow)
There are situations where I need to query multiple posts. For example when trying to create a feed based on different metrics than supported (i.e: Top Viewed Peakd). This results in batching multiple requests via Promise.all(). I think it would be better if an array of author/permlink could be set, which returns an array of posts, making only a single request.
Edited by Dan Notestein