Skip to content
Snippets Groups Projects
Commit 9a0f901e authored by Andrzej Lisak's avatar Andrzej Lisak
Browse files

Merge branch 'mt-fix-tests' of gitlab.syncad.com:hive/hivemind into mt-fix-tests

parents eec369bd d5e21b61
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,!68Fixed result of inaccurate assumption
...@@ -207,7 +207,7 @@ class Blocks: ...@@ -207,7 +207,7 @@ class Blocks:
if not is_initial_sync: if not is_initial_sync:
Accounts.dirty(op['author']) # lite - rep Accounts.dirty(op['author']) # lite - rep
Accounts.dirty(op['voter']) # lite - stats Accounts.dirty(op['voter']) # lite - stats
Votes.vote_op(op) Votes.vote_op(op, cls._head_block_date)
# misc ops # misc ops
elif op_type == 'transfer_operation': elif op_type == 'transfer_operation':
......
...@@ -161,7 +161,6 @@ class Posts: ...@@ -161,7 +161,6 @@ class Posts:
payout = COALESCE( CAST( data_source.payout as DECIMAL ), ihp.payout ), payout = COALESCE( CAST( data_source.payout as DECIMAL ), ihp.payout ),
pending_payout = COALESCE( CAST( data_source.pending_payout as DECIMAL ), ihp.pending_payout ), pending_payout = COALESCE( CAST( data_source.pending_payout as DECIMAL ), ihp.pending_payout ),
payout_at = COALESCE( CAST( data_source.payout_at as TIMESTAMP ), ihp.payout_at ), payout_at = COALESCE( CAST( data_source.payout_at as TIMESTAMP ), ihp.payout_at ),
updated_at = data_source.updated_at,
last_payout = COALESCE( CAST( data_source.last_payout as TIMESTAMP ), ihp.last_payout ), last_payout = COALESCE( CAST( data_source.last_payout as TIMESTAMP ), ihp.last_payout ),
cashout_time = COALESCE( CAST( data_source.cashout_time as TIMESTAMP ), ihp.cashout_time ), cashout_time = COALESCE( CAST( data_source.cashout_time as TIMESTAMP ), ihp.cashout_time ),
is_paidout = COALESCE( CAST( data_source.is_paidout as BOOLEAN ), ihp.is_paidout ) is_paidout = COALESCE( CAST( data_source.is_paidout as BOOLEAN ), ihp.is_paidout )
...@@ -177,7 +176,6 @@ class Posts: ...@@ -177,7 +176,6 @@ class Posts:
t.payout, t.payout,
t.pending_payout, t.pending_payout,
t.payout_at, t.payout_at,
t.updated_at,
t.last_payout, t.last_payout,
t.cashout_time, t.cashout_time,
t.is_paidout t.is_paidout
...@@ -196,7 +194,6 @@ class Posts: ...@@ -196,7 +194,6 @@ class Posts:
payout, payout,
pending_payout, pending_payout,
payout_at, payout_at,
updated_at,
last_payout, last_payout,
cashout_time, cashout_time,
is_paidout) is_paidout)
...@@ -310,7 +307,7 @@ class Posts: ...@@ -310,7 +307,7 @@ class Posts:
payout_at = date #Here should be `cashout_time` payout_at = date #Here should be `cashout_time`
last_payout = date last_payout = date
cls._comment_payout_ops.append("('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {}, {}, '{}'::timestamp, {}, {}, {})".format( cls._comment_payout_ops.append("('{}', '{}', {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})".format(
author, author,
permlink, permlink,
"NULL" if ( total_payout_value is None ) else ( "'{}'".format( legacy_amount(total_payout_value) ) ), "NULL" if ( total_payout_value is None ) else ( "'{}'".format( legacy_amount(total_payout_value) ) ),
...@@ -323,7 +320,6 @@ class Posts: ...@@ -323,7 +320,6 @@ class Posts:
"NULL" if ( pending_payout is None ) else pending_payout, "NULL" if ( pending_payout is None ) else pending_payout,
"NULL" if ( payout_at is None ) else ( "'{}'::timestamp".format( payout_at ) ), "NULL" if ( payout_at is None ) else ( "'{}'::timestamp".format( payout_at ) ),
date,#updated_at
"NULL" if ( last_payout is None ) else ( "'{}'::timestamp".format( last_payout ) ), "NULL" if ( last_payout is None ) else ( "'{}'::timestamp".format( last_payout ) ),
"NULL" if ( cashout_time is None ) else ( "'{}'::timestamp".format( cashout_time ) ), "NULL" if ( cashout_time is None ) else ( "'{}'::timestamp".format( cashout_time ) ),
......
...@@ -49,11 +49,12 @@ class Votes: ...@@ -49,11 +49,12 @@ class Votes:
inside_flush = False inside_flush = False
@classmethod @classmethod
def vote_op(cls, vop): def vote_op(cls, vote_operation, date):
""" Process vote_operation """ """ Process vote_operation """
voter = vop['voter'] voter = vote_operation['voter']
author = vop['author'] author = vote_operation['author']
permlink = vop['permlink'] permlink = vote_operation['permlink']
weight = vote_operation['weight']
if(cls.inside_flush): if(cls.inside_flush):
log.info("Adding new vote-info into '_votes_data' dict") log.info("Adding new vote-info into '_votes_data' dict")
...@@ -64,10 +65,10 @@ class Votes: ...@@ -64,10 +65,10 @@ class Votes:
cls._votes_data[key] = dict(voter=voter, cls._votes_data[key] = dict(voter=voter,
author=author, author=author,
permlink=permlink, permlink=permlink,
vote_percent=0, vote_percent=weight,
weight=0, weight=0,
rshares=0, rshares=0,
last_update="1969-12-31T23:59:59") last_update=date)
@classmethod @classmethod
def effective_comment_vote_op(cls, key, vop, date): def effective_comment_vote_op(cls, key, vop, date):
...@@ -79,7 +80,6 @@ class Votes: ...@@ -79,7 +80,6 @@ class Votes:
assert key in cls._votes_data assert 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]["weight"] = vop["weight"]
cls._votes_data[key]["rshares"] = vop["rshares"] cls._votes_data[key]["rshares"] = vop["rshares"]
cls._votes_data[key]["last_update"] = date cls._votes_data[key]["last_update"] = date
...@@ -90,33 +90,28 @@ class Votes: ...@@ -90,33 +90,28 @@ class Votes:
cls.inside_flush = True cls.inside_flush = True
if cls._votes_data: if cls._votes_data:
sql = """ sql = """
INSERT INTO hive_votes INSERT INTO hive_votes
(post_id, voter_id, author_id, permlink_id, weight, rshares, vote_percent, last_update) (post_id, voter_id, author_id, permlink_id, weight, rshares, vote_percent, last_update)
select data_source.post_id, data_source.voter_id, data_source.author_id, data_source.permlink_id, data_source.weight, data_source.rshares, data_source.vote_percent, data_source.last_update SELECT hp.id as post_id, ha_v.id as voter_id, ha_a.id as author_id, hpd_p.id as permlink_id, t.weight, t.rshares, t.vote_percent, t.last_update
from FROM
( (
SELECT hp.id as post_id, ha_v.id as voter_id, ha_a.id as author_id, hpd_p.id as permlink_id, t.weight, t.rshares, t.vote_percent, t.last_update VALUES
from -- voter, author, permlink, weight, rshares, vote_percent, last_update
( {}
VALUES ) AS T(voter, author, permlink, weight, rshares, vote_percent, last_update)
-- voter, author, permlink, weight, rshares, vote_percent, last_update INNER JOIN hive_accounts ha_v ON ha_v.name = t.voter
{} INNER JOIN hive_accounts ha_a ON ha_a.name = t.author
) AS T(voter, author, permlink, weight, rshares, vote_percent, last_update) INNER JOIN hive_permlink_data hpd_p ON hpd_p.permlink = t.permlink
INNER JOIN hive_accounts ha_v ON ha_v.name = t.voter INNER JOIN hive_posts hp ON hp.author_id = ha_a.id AND hp.permlink_id = hpd_p.id
INNER JOIN hive_accounts ha_a ON ha_a.name = t.author ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO
INNER JOIN hive_permlink_data hpd_p ON hpd_p.permlink = t.permlink UPDATE
INNER JOIN hive_posts hp ON hp.author_id = ha_a.id AND hp.permlink_id = hpd_p.id SET
) as data_source(post_id, voter_id, author_id, permlink_id, weight, rshares, vote_percent, last_update) weight = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.weight ELSE EXCLUDED.weight END),
ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO rshares = (CASE (SELECT hp.is_paidout FROM hive_posts hp WHERE hp.id = EXCLUDED.id) WHEN true THEN hive_votes.rshares ELSE EXCLUDED.rshares END),
UPDATE vote_percent = EXCLUDED.vote_percent,
SET last_update = EXCLUDED.last_update,
weight = EXCLUDED.weight, num_changes = hive_votes.num_changes + 1
rshares = EXCLUDED.rshares, """
vote_percent = EXCLUDED.vote_percent,
last_update = EXCLUDED.last_update,
num_changes = hive_votes.num_changes + 1
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 = [] values = []
values_limit = 1000 values_limit = 1000
......
Subproject commit 113cb05cc2dc35fe6e6e149fc3ecb8ae286d4cc4 Subproject commit 779f69cf2171b2dd6259cb6fc300cd3bea737edc
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