You are viewing a single comment's thread from:

RE: SteemWorld ~ Newsletter #3 / February, 2018

in #steem7 years ago

Hey man!

Excellent work with SteemWorld, it's a great app which I use all the time.

I was wondering if you could help me with something regarding the delegations 'out'.

I'm looking at the table an I cant work out the logic to list the current active delegations. I'd be using SQL (and I think you could be using something else), but any clues on to list just the active delegations would be great.

I see the vesting_shares = 0.0000 is the end of a delegation, but Im unsure how to code the 'active' list, particularly if a delegation has ended, and restarted for the same users.

Any advice would be much appreciated!

Thanks again for your work!

Sort:  

Thanks man! If you want to build it on your own with SQL, you need to look for the last 'delegate_vesting_shares' operation with the desired combination of 'delegator' and 'delegatee':

SELECT vesting_shares FROM [table] WHERE delegator = [1] AND delegatee = [2] ORDER BY [date] DESC LIMIT 1

To retrieve all active outgoing delegations for an account you will also need some grouping/joining to select each group ( delegator + delegatee ) with the last date. I think I would do it with MAX( [date] ) so that for each group only the row with highest date will be returned. To reach optimal performance I would recommend to test a few different queries (depending on existing indices for the table and type of your used SQL server).

You could also use SteemJS ( steem.api.getVestingDelegationsAsync() ) or just make a direct curl() to a steem node with 'get_vesting_delegations' to achieve that.