diff --git a/hive/indexer/blocks.py b/hive/indexer/blocks.py index 3c879d2d704fe67d6f143beb5d717178bd515923..f3603bbbc276a9829a75e0aaf7eb05d5ad2aed0a 100644 --- a/hive/indexer/blocks.py +++ b/hive/indexer/blocks.py @@ -107,33 +107,29 @@ class Blocks: op_type = vop['type'] op_value = vop['value'] - if op_type == 'curation_reward_operation': key = "{}/{}".format(op_value['comment_author'], op_value['comment_permlink']) - val = {'reward' : op_value['reward'], 'author':op_value['comment_author'], 'permlink': op_value['comment_permlink'] } + val = {'reward' : op_value['reward']} elif op_type == 'author_reward_operation': key = "{}/{}".format(op_value['author'], op_value['permlink']) - val = {'hbd_payout':op_value['hbd_payout'], 'hive_payout':op_value['hive_payout'], 'vesting_payout':op_value['vesting_payout'], 'author':op_value['author'], 'permlink': op_value['permlink'] } + val = {'hbd_payout':op_value['hbd_payout'], 'hive_payout':op_value['hive_payout'], 'vesting_payout':op_value['vesting_payout']} elif op_type == 'comment_reward_operation': key = "{}/{}".format(op_value['author'], op_value['permlink']) - val = {'payout':op_value['payout'], 'author_rewards':op_value['author_rewards'], 'total_payout_value':op_value['total_payout_value'], 'curator_payout_value':op_value['curator_payout_value'], 'beneficiary_payout_value':op_value['beneficiary_payout_value'], 'author':op_value['author'], 'permlink': op_value['permlink'] } + val = {'payout':op_value['payout'], 'author_rewards':op_value['author_rewards'], 'total_payout_value':op_value['total_payout_value'], 'curator_payout_value':op_value['curator_payout_value'], 'beneficiary_payout_value':op_value['beneficiary_payout_value'] } elif op_type == 'effective_comment_vote_operation': key = "{}/{}".format(op_value['author'], op_value['permlink']) - val = {'pending_payout':op_value['pending_payout'], 'author':op_value['author'], 'permlink': op_value['permlink'] } + val = {'pending_payout':op_value['pending_payout']} vote_ops.append(vop) elif op_type == 'comment_payout_update_operation': key = "{}/{}".format(op_value['author'], op_value['permlink']) - val = {'is_paidout': True, 'author':op_value['author'], 'permlink': op_value['permlink'] } # comment_payout_update_operation implicates is_paidout (is generated only when post is paidout) + val = {'is_paidout': True} # comment_payout_update_operation implicates is_paidout (is generated only when post is paidout) if key is not None and val is not None: - if op_type in comment_payout_ops: - if ( key in comment_payout_ops[ op_type ] ) and ( op_type != 'curation_reward_operation' ): - comment_payout_ops[ op_type ][ key ] = val - else: - comment_payout_ops[ op_type ].append( { key:val } ) + if key in comment_payout_ops: + comment_payout_ops[key].append({op_type:val}) else: - comment_payout_ops[ op_type ] = [ { key:val } ] + comment_payout_ops[key] = [{op_type:val}] return (vote_ops, comment_payout_ops) diff --git a/hive/indexer/posts.py b/hive/indexer/posts.py index 438e2175f51acb85711a0fbe2fd6539b0db0d0a9..b145327fcfd6335ca2a346a61053a2c13c0cd7c8 100644 --- a/hive/indexer/posts.py +++ b/hive/indexer/posts.py @@ -208,7 +208,8 @@ class Posts: values_limit = 1000 """ Process comment payment operations """ - for op, v in ops.items(): + for k, v in ops.items(): + author, permlink = k.split("/") # total payout to curators curator_rewards_sum = None @@ -234,19 +235,15 @@ class Posts: is_paidout = None - for data in v: - for key, value in data.items(): + for operation in v: + for op, value in operation.items(): if op in ops_stats: ops_stats[op] += 1 else: ops_stats[op] = 1 - author = value["author"] - permlink = value["permlink"] - if op == 'curation_reward_operation': - if curator_rewards_sum is None: - curator_rewards_sum = 0 + curator_rewards_sum = 0 curator_rewards_sum = curator_rewards_sum + int(value['reward']['amount']) elif op == 'author_reward_operation': author_rewards_hive = value['hive_payout']['amount']