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 *_v2 shape from #348 (closed): no active_votes, with observer_vote and optional top_votes. A post that doesn't exist (or is deleted) is null in its position, so clients can map results back.
  1. New postgrest/bridge_api/bridge_api_get_posts.sql. Validate the posts shape (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 with create_bridge_post_object(…, _votes_mode => 1, _top_votes => …) as the *_v2 endpoints do.
  2. Register it in postgrest/utilities/get_api_method.sql (get_bridge_method) and in postgrest/load_order.sql (#351 (closed)'s manifest).
  3. Document it next to the *_v2 calls in docs/bridge-votes.md.

Acceptance

  • Tavern patterns:
    • a positive pattern requesting posts that existing get_post_v2 patterns 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 null in that position;
    • negative patterns for 0 entries, 101 entries, a malformed pair, and top_votes: 11.
  • 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