Simple stats dashboard for curators and witnesses

Today I'm releasing two simple HAF-powered dashboards that some may be interested in as it has been a hot topic of discussion lately.

These pages are built with Bootstrap 5 and may be a precursor to a more comprehensive personal dashboard that I (or someone else) may wish to build later.


Curation Summary

Curation has been widely discussed recently, besides the krampus co-efficient, another metric being used by some is the voting CSI score. In short, it shows how spread out their curation activities are taking weights of upvotes and the number of unique accounts voted in the last 7 days, higher the better. This metric was taken from Hivetasks (forked from SteemWorld) and adopted for the curation summary dashboard.

The first step was to determine the voting CSI formula, which can be found here. This was the part many could not find, however it took only 5 minutes to search and around 15 minutes to decipher what some variables mean.

Next step was to obtain the data required to calculate the score. Hivetasks calls account history API for the last 7 days to construct the source data which is not the most efficient way. As this isn't something standard APIs currently provide, I took advantage of having access to a HAF database with to query the voting data more efficiently. The query requires hivemind_app to be synced.

! [Click to reveal function]

CREATE OR REPLACE FUNCTION witstats_api.outgoing_votes_summary(voter VARCHAR, last_days INT, direction INT)
RETURNS jsonb AS $function$
BEGIN
 IF (SELECT hive.is_app_in_sync('hivemind_app') IS FALSE) THEN
   RAISE EXCEPTION 'hivemind_app is not in sync';
 END IF;
 IF last_days < 1 OR last_days > 30 THEN
   RAISE EXCEPTION 'last_days must be between 1 and 30';
 ELSIF direction != 1 AND direction != 2 THEN
   RAISE EXCEPTION 'direction must be 1 (upvote) or 2 (downvote)';
 ELSIF voter IS NULL OR LENGTH(voter) = 0 THEN
   RAISE EXCEPTION 'invalid voter';
 END IF;
 RETURN (
   WITH summary AS (
     SELECT aa.name as author, SUM(vote_percent) as vote_weight_agg, COUNT(v.author_id) as vote_count
     FROM hivemind_app.hive_votes v
     JOIN hivemind_app.hive_accounts aa ON
       aa.id = v.author_id
     JOIN hivemind_app.hive_accounts va ON
       va.id = v.voter_id
     WHERE va.name = voter AND v.last_update > NOW()::TIMESTAMP - (last_days * interval '1 day') AND (SELECT CASE WHEN direction = 1 THEN vote_percent > 0 ELSE vote_percent < 0 END)
     GROUP BY aa.name
     ORDER BY vote_count DESC, vote_weight_agg DESC
   )
   SELECT jsonb_agg(jsonb_build_object(
     'author', s.author,
     'weights', s.vote_weight_agg,
     'count', s.vote_count
   ))
   FROM summary s
 );
END $function$
LANGUAGE plpgsql STABLE;

The page is available here. You may append a user query parameter to the URL to specify the username on initial page load, like this.

Page source code may be found here.


Witness Reward Stats

This is for those that want to know producer rewards and number of blocks produced of a witness over a certain period of time. The data goes all the way back to the genesis block or the first block the witness has ever produced, whichever is later. This does not include producer rewards paid in liquid HIVE which may be the case prior to block 864,000.

The chart is available at daily, monthly and yearly intervals. Total HIVE rewards displayed here are converted from VESTS at time of block production.

The page is available here. Just like curation summary, you may also append a user query parameter to the URL to specify the username on initial page load, like this.

Source code of the HAF app and frontend may be found here.

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
11 Comments