Skip to content
Snippets Groups Projects
Commit 3b86f560 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'mt-votes-fixes' into 'develop'

Mt votes fixes

See merge request !59
parents 044364f2 ce97df1b
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,!59Mt votes fixes
......@@ -99,7 +99,7 @@ class Blocks:
@staticmethod
def prepare_vops(vopsList, date):
vote_ops = []
vote_ops = {}
comment_payout_ops = {}
for vop in vopsList:
key = None
......@@ -119,7 +119,8 @@ class Blocks:
key = "{}/{}".format(op_value['author'], op_value['permlink'])
val = {'payout':op_value['payout'], 'author_rewards':op_value['author_rewards']}
elif op_type == 'effective_comment_vote_operation':
vote_ops.append(vop)
key_vote = "{}/{}/{}".format(op_value['voter'], op_value['author'], op_value['permlink'])
vote_ops[ key_vote ] = op_value
if key is not None and val is not None:
if key in comment_payout_ops:
......@@ -199,6 +200,7 @@ class Blocks:
Accounts.dirty(op['author']) # lite - rep
Accounts.dirty(op['voter']) # lite - stats
update_comment_pending_payouts.append([op['author'], op['permlink']])
Votes.vote_op(op)
# misc ops
elif op_type == 'transfer_operation':
......@@ -217,7 +219,7 @@ class Blocks:
# virtual ops
comment_payout_ops = {}
vote_ops = []
vote_ops = {}
empty_vops = (vote_ops, comment_payout_ops)
......@@ -227,14 +229,8 @@ class Blocks:
vops = hived.get_virtual_operations(num)
(vote_ops, comment_payout_ops) = Blocks.prepare_vops(vops, cls._head_block_date)
for v in vote_ops:
Votes.vote_op(v, cls._head_block_date)
op_type = v['type']
if op_type in cls.ops_stats:
cls.ops_stats[op_type] += 1
else:
cls.ops_stats[op_type] = 1
for k, v in vote_ops.items():
Votes.effective_comment_vote_op(k, v, cls._head_block_date)
if comment_payout_ops:
comment_payout_stats = Posts.comment_payout_op(comment_payout_ops, cls._head_block_date)
......
......@@ -55,14 +55,14 @@ class Votes:
inside_flush = False
@classmethod
def vote_op(cls, vop, date):
def vote_op(cls, vop):
""" Process vote_operation """
voter = vop['value']['voter']
author = vop['value']['author']
permlink = vop['value']['permlink']
voter = vop['voter']
author = vop['author']
permlink = vop['permlink']
if(cls.inside_flush):
log.info("Adding new vote-info into _votes_data dict")
log.info("Adding new vote-info into '_votes_data' dict")
raise "Fatal error"
key = voter + "/" + author + "/" + permlink
......@@ -70,10 +70,24 @@ class Votes:
cls._votes_data[key] = dict(voter=voter,
author=author,
permlink=permlink,
vote_percent=vop['value']['vote_percent'],
weight=vop['value']['weight'],
rshares=vop['value']['rshares'],
last_update=date)
vote_percent=0,
weight=0,
rshares=0,
last_update="1969-12-31T23:59:59")
@classmethod
def effective_comment_vote_op(cls, key, vop, date):
""" Process effective_comment_vote_operation """
if(cls.inside_flush):
log.info("Updating data in '_votes_data' using effective comment")
raise "Fatal error"
if key in cls._votes_data:
cls._votes_data[key]["vote_percent"] = vop["vote_percent"]
cls._votes_data[key]["weight"] = vop["weight"]
cls._votes_data[key]["rshares"] = vop["rshares"]
cls._votes_data[key]["last_update"] = date
@classmethod
def flush(cls):
......@@ -106,7 +120,7 @@ class Votes:
vote_percent = EXCLUDED.vote_percent,
last_update = EXCLUDED.last_update,
num_changes = hive_votes.num_changes + 1
WHERE hive_votes.id = EXCLUDED.id
WHERE hive_votes.voter_id = EXCLUDED.voter_id and hive_votes.author_id = EXCLUDED.author_id and hive_votes.permlink_id = EXCLUDED.permlink_id;
"""
values = []
......
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