Skip to content

feat(api): implement active_votes, payout branches, fix N+1 (PR#5a) - #382

Open
ety001 wants to merge 1 commit into
nextfrom
feature/pr5a-active-votes-payout
Open

feat(api): implement active_votes, payout branches, fix N+1 (PR#5a)#382
ety001 wants to merge 1 commit into
nextfrom
feature/pr5a-active-votes-payout

Conversation

@ety001

@ety001 ety001 commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

First step of the get_discussion gray-release milestone (solving the production connection-pool exhaustion incidents). Makes buildPostObject produce condenser-compatible output by implementing the three TODO stubs that previously returned empty/wrong data.

Changes

active_votes parsing (was []interface{}{} TODO)

  • Parse the hive_posts_cache.votes CSV (format: voter,rshares,percent,reputation per line) into steemd-style vote objects.
  • Reputation converted via repToRaw (mirrors legacy _hydrate_active_votes + rep_to_raw).

payout branches (was cache.Payout for both — wrong)

  • Implement is_paidout branch: total_payout_value vs pending_payout_value, last_payout vs cashout_time.
  • Matches legacy condenser_api/objects.py:159-165.
  • Add total_votes field.

N+1 fixes (connection-pool-exhaustion Issues 3 & from objects audit)

  • PostLoader O(n²)→O(n): build a postMap for O(1) ID lookup instead of linear scan per ID.
  • LoadPostsReblogs N+1: batch-load all reblogger account names in one query instead of per-pair.

Helpers + tests

  • repToRaw, formatAmount, hydrateActiveVotes, payoutDate — all unit-tested.
  • Mirrors legacy utils/normalize.py:rep_to_raw and condenser_api/objects.py:_amount.

Validation

  • go build / go vet / go test ./... all green.
  • Unit tests: vote CSV parsing (empty/single/multi/malformed), rep conversion (25→0, 34→1e10, 52→1e12, negative), amount formatting.

Why this matters

These functions are the building blocks reused by load_posts_keyed (PR#5b) and get_discussion (PR#5c). Without active_votes and correct payout, the api-comparison tool flags every post-returning method as a mismatch.

Test plan

  • CI green

Part of the get_discussion gray-release milestone. Depends on #381 (test infra, already merged).

…+1 (PR#5a)

First step of the get_discussion gray-release milestone. Makes
buildPostObject produce condenser-compatible output by implementing
the three TODO stubs that produced empty/wrong data.

- active_votes: parse the hive_posts_cache.votes CSV (format:
  voter,rshares,percent,reputation per line) into steemd-style vote
  objects, with reputation converted via repToRaw (mirrors legacy
  _hydrate_active_votes + rep_to_raw).
- payout: implement the is_paidout branch — total_payout_value vs
  pending_payout_value, last_payout vs cashout_time — matching legacy
  condenser_api/objects.py:159-165. Add total_votes field.
- PostLoader O(n²)→O(n): build a postMap for O(1) ID lookup instead
  of linear scan per ID (connection-pool-exhaustion Issue 3).
- LoadPostsReblogs N+1: batch-load all reblogger account names in
  one query instead of per-pair (was N queries for N reblogged posts).
- Add repToRaw, formatAmount, hydrateActiveVotes, payoutDate helpers
  with unit tests.

These functions are reused by load_posts_keyed (PR#5b) and
get_discussion (PR#5c).
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.

1 participant