RE: How SPS Stakeholders and Staking HP and HBD?

You are viewing a single comment's thread:

There is no historical tracking of delegations. There are only current values available.



0
0
0.000
4 comments
avatar

Oke clear. you cannot have everything 😁 some limitation over performance that is the question.

@azricon, how important do think it is to include the delegations?

0
0
0.000
avatar

I can take a look later to see if I can come up with a query that tracks historical delegations and make that a materialized view which can refresh once an hour or so depending on the query.

0
0
0.000
avatar

Do not what to spam you 😂. But i found a another method to limit the call that i will commit for now

This does the first last record and every first of the month, exactly what is want

WITH bh AS (
  SELECT
    bh.*,
    hb.timestamp AS block_timestamp,
    date_trunc('month', hb.timestamp) AS month_start,
    ROW_NUMBER() OVER (
      PARTITION BY bh.account_name
      ORDER BY bh.block_num ASC
    ) AS rn_first,
    ROW_NUMBER() OVER (
      PARTITION BY bh.account_name
      ORDER BY bh.block_num DESC
    ) AS rn_last,
    ROW_NUMBER() OVER (
      PARTITION BY bh.account_name, date_trunc('month', hb.timestamp)
      ORDER BY hb.timestamp ASC, bh.block_num ASC
    ) AS rn_month
  FROM hafsql.balances_history bh
  JOIN hafsql.haf_blocks hb
    ON hb.block_num = bh.block_num
  WHERE bh.account_name IN ({placeholders})
)
SELECT
  *
FROM bh
WHERE rn_first = 1
   OR rn_last  = 1
   OR rn_month = 1
ORDER BY account_name, block_num DESC;

limited the number of account at once to 5

Thanks again for the help 🙏

0
0
0.000
avatar

You are not spamming. This one takes too long for top witnesses.

0
0
0.000