Skip to content
Snippets Groups Projects
Commit 4b8809a1 authored by Mariusz Trela's avatar Mariusz Trela
Browse files

Added `ineffective_delete_comment_operation`

parent a8b12386
No related branches found
No related tags found
4 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!135Enable postgres monitoring on CI server,!86Post are removed correctly
...@@ -541,7 +541,7 @@ def setup(db): ...@@ -541,7 +541,7 @@ def setup(db):
$function$ $function$
BEGIN BEGIN
RETURN QUERY UPDATE hive_posts AS hp RETURN QUERY UPDATE hive_posts AS hp
SET hp.counter_deleted = SET counter_deleted =
( (
SELECT max( hp.counter_deleted ) + 1 SELECT max( hp.counter_deleted ) + 1
FROM hive_posts hp FROM hive_posts hp
......
...@@ -106,7 +106,8 @@ class Blocks: ...@@ -106,7 +106,8 @@ class Blocks:
@staticmethod @staticmethod
def prepare_vops(comment_payout_ops, vopsList, date): def prepare_vops(comment_payout_ops, vopsList, date):
vote_ops = {} vote_ops = {}
ops_stats = { 'author_reward_operation' : 0, 'comment_reward_operation' : 0, 'effective_comment_vote_operation' : 0, 'comment_payout_update_operation' : 0 } ops_stats = { 'author_reward_operation' : 0, 'comment_reward_operation' : 0, 'effective_comment_vote_operation' : 0, 'comment_payout_update_operation' : 0, 'ineffective_delete_comment_operation' : 0 }
inefficient_deleted_ops = {}
for vop in vopsList: for vop in vopsList:
key = None key = None
...@@ -151,8 +152,11 @@ class Blocks: ...@@ -151,8 +152,11 @@ class Blocks:
comment_payout_ops[key] = { 'author_reward_operation':None, 'comment_reward_operation':None, 'effective_comment_vote_operation':None, 'comment_payout_update_operation':None, 'date' : date } comment_payout_ops[key] = { 'author_reward_operation':None, 'comment_reward_operation':None, 'effective_comment_vote_operation':None, 'comment_payout_update_operation':None, 'date' : date }
comment_payout_ops[key][op_type] = op_value comment_payout_ops[key][op_type] = op_value
elif op_type == 'ineffective_delete_comment_operation':
ops_stats[ 'ineffective_delete_comment_operation' ] += 1
inefficient_deleted_ops[key] = {}
return (vote_ops, ops_stats) return (vote_ops, ops_stats, inefficient_deleted_ops)
@classmethod @classmethod
...@@ -170,6 +174,17 @@ class Blocks: ...@@ -170,6 +174,17 @@ class Blocks:
if cls._head_block_date is None: if cls._head_block_date is None:
cls._head_block_date = cls._current_block_date cls._head_block_date = cls._current_block_date
vote_ops = None
comment_payout_stats = None
inefficient_deleted_ops = None
if is_initial_sync:
if num in virtual_operations:
(vote_ops, comment_payout_stats, inefficient_deleted_ops ) = Blocks.prepare_vops(Posts.comment_payout_ops, virtual_operations[num], cls._current_block_date)
else:
vops = hived.get_virtual_operations(num)
(vote_ops, comment_payout_stats, inefficient_deleted_ops ) = Blocks.prepare_vops(Posts.comment_payout_ops, vops, cls._current_block_date)
json_ops = [] json_ops = []
for tx_idx, tx in enumerate(block['transactions']): for tx_idx, tx in enumerate(block['transactions']):
for operation in tx['operations']: for operation in tx['operations']:
...@@ -205,7 +220,9 @@ class Blocks: ...@@ -205,7 +220,9 @@ class Blocks:
if not is_initial_sync: if not is_initial_sync:
Accounts.dirty(op['author']) # lite - stats Accounts.dirty(op['author']) # lite - stats
elif op_type == 'delete_comment_operation': elif op_type == 'delete_comment_operation':
Posts.delete_op(op) key = "{}/{}".format(op['author'], op['permlink'])
if ( inefficient_deleted_ops is None ) or ( key not in inefficient_deleted_ops ):
Posts.delete_op(op)
elif op_type == 'comment_options_operation': elif op_type == 'comment_options_operation':
Posts.comment_options_op(op) Posts.comment_options_op(op)
elif op_type == 'vote_operation': elif op_type == 'vote_operation':
...@@ -231,16 +248,6 @@ class Blocks: ...@@ -231,16 +248,6 @@ class Blocks:
custom_ops_stats = CustomOp.process_ops(json_ops, num, cls._head_block_date) custom_ops_stats = CustomOp.process_ops(json_ops, num, cls._head_block_date)
cls.ops_stats = Blocks.merge_ops_stats(cls.ops_stats, custom_ops_stats) cls.ops_stats = Blocks.merge_ops_stats(cls.ops_stats, custom_ops_stats)
vote_ops = None
comment_payout_stats = None
if is_initial_sync:
if num in virtual_operations:
(vote_ops, comment_payout_stats) = Blocks.prepare_vops(Posts.comment_payout_ops, virtual_operations[num], cls._current_block_date)
else:
vops = hived.get_virtual_operations(num)
(vote_ops, comment_payout_stats) = Blocks.prepare_vops(Posts.comment_payout_ops, vops, cls._current_block_date)
if vote_ops is not None: if vote_ops is not None:
for k, v in vote_ops.items(): for k, v in vote_ops.items():
Votes.effective_comment_vote_op(k, v) Votes.effective_comment_vote_op(k, v)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment