From d552aaa98edaa587541c43a739e5ed17252f72e4 Mon Sep 17 00:00:00 2001
From: mtrela <mtrela@syncad.com>
Date: Mon, 27 Jul 2020 09:53:03 +0200
Subject: [PATCH] Grouping by operation id is reverted

---
 hive/indexer/blocks.py | 20 ++++++++------------
 hive/indexer/posts.py  | 13 +++++--------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/hive/indexer/blocks.py b/hive/indexer/blocks.py
index 3c879d2d7..f3603bbbc 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 438e2175f..b145327fc 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']
-- 
GitLab