Words
142
Reading
1 min
Listen
Play
1y
Hi thanks for dropping a comment,
I have took a look on those tables. Do you also got some documentation.
Because for me its not clear what the balance is.
balance_history_by_day i assume that is the HP in VESTS?
saving_history_by_day is that the hive saving in vest or hdb saving.
That is why i like the balance_history view a bit more because that a name that i know 😁. and it does the account name mapping directly.
also in my react code i did a call a bit smarter to limit the result directly.
SELECT * FROM (
SELECT
bh.*,
hb.timestamp as block_timestamp,
ROW_NUMBER() OVER (PARTITION BY bh.account_name ORDER BY bh.block_num ASC) AS rn_asc,
ROW_NUMBER() OVER (PARTITION BY bh.account_name ORDER BY bh.block_num DESC) AS rn_desc
FROM hafsql.balances_history bh
LEFT JOIN hafsql.haf_blocks hb ON bh.block_num = hb.block_num
WHERE bh.account_name IN (${placeholders})
) sub
WHERE rn_asc = 1 -- first row per account
OR rn_desc = 1 -- last row per account
OR (block_num % 100 = 0) -- every 100th block
ORDER BY account_name, block_num DESC
the python wrapper whas a bit rushed coding, and did not do the partition well, but i like to learn end i might end up using the two tables you recommend.
Lots of data to go trough but really nice you create/maintaining the hafSQL looks really impressive 👏
RE: How SPS Stakeholders and Staking HP and HBD?