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

Merge branch 'mixed_fix1' into 'develop'

Some fixes related to get_state as well as vote handling

See merge request !60
parents 3b86f560 6dbdd6de
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,!60Some fixes related to get_state as well as vote handling
......@@ -717,7 +717,7 @@ def setup(db):
CREATE VIEW hive_votes_accounts_permlinks_view
AS
SELECT
ha_v.id as id,
ha_v.id as voter_id,
ha_a.name as author,
hpd.permlink as permlink,
vote_percent as percent,
......
......@@ -217,11 +217,6 @@ class Sync:
if not CONTINUE_PROCESSING:
return
DbState.finish_initial_sync()
if self._conf.get("exit_after_sync"):
log.info("Exiting after sync on user request...")
return
else:
# recover from fork
Blocks.verify_head(self._steem)
......@@ -231,6 +226,9 @@ class Sync:
if self._conf.get('test_max_block'):
# debug mode: partial sync
return self.from_steemd()
if self._conf.get("exit_after_sync"):
log.info("Exiting after sync on user request...")
return
if self._conf.get('test_disable_sync'):
# debug mode: no sync, just stream
return self.listen()
......
......@@ -15,11 +15,9 @@ class Votes:
def get_vote_count(cls, author, permlink):
""" Get vote count for given post """
sql = """
SELECT count(hv.id)
FROM hive_votes hv
INNER JOIN hive_accounts ha_a ON ha_a.id = hv.author_id
INNER JOIN hive_permlink_data hpd_p ON hpd_p.id = hv.permlink_id
WHERE ha_a.name = :author AND hpd_p.permlink = :permlink
SELECT count(1)
FROM hive_votes_accounts_permlinks_view hv
WHERE hv.author = :author AND hv.permlink = :permlink
"""
ret = DB.query_row(sql, author=author, permlink=permlink)
return 0 if ret is None else int(ret.count)
......@@ -28,12 +26,10 @@ class Votes:
def get_upvote_count(cls, author, permlink):
""" Get vote count for given post """
sql = """
SELECT count(hv.id)
FROM hive_votes hv
INNER JOIN hive_accounts ha_a ON ha_a.id = hv.author_id
INNER JOIN hive_permlink_data hpd_p ON hpd_p.id = hv.permlink_id
WHERE ha_a.name = :author AND hpd_p.permlink = :permlink
vote_percent > 0
SELECT count(1)
FROM hive_votes_accounts_permlinks_view hv
WHERE hv.author = :author AND hv.permlink = :permlink
AND hv.percent > 0
"""
ret = DB.query_row(sql, author=author, permlink=permlink)
return 0 if ret is None else int(ret.count)
......@@ -42,12 +38,10 @@ class Votes:
def get_downvote_count(cls, author, permlink):
""" Get vote count for given post """
sql = """
SELECT count(hv.id)
FROM hive_votes hv
INNER JOIN hive_accounts ha_a ON ha_a.id = hv.author_id
INNER JOIN hive_permlink_data hpd_p ON hpd_p.id = hv.permlink_id
WHERE ha_a.name = :author AND hpd_p.permlink = :permlink
vote_percent < 0
SELECT count(1)
FROM hive_votes_accounts_permlinks_view hv
WHERE hv.author = :author AND hv.permlink = :permlink
AND hv.percent < 0
"""
ret = DB.query_row(sql, author=author, permlink=permlink)
return 0 if ret is None else int(ret.count)
......@@ -110,7 +104,7 @@ class Votes:
INNER JOIN hive_accounts ha_v ON ha_v.name = t.voter
INNER JOIN hive_accounts ha_a ON ha_a.name = t.author
INNER JOIN hive_permlink_data hpd_p ON hpd_p.permlink = t.permlink
INNER JOIN hive_posts hp ON hp.author_id = ha_a.id AND hp.permlink_id = hpd_p.id
INNER JOIN hive_posts hp ON hp.author_id = ha_a.id AND hp.permlink_id = hpd_p.id
) as data_source(post_id, voter_id, author_id, permlink_id, weight, rshares, vote_percent, last_update)
ON CONFLICT ON CONSTRAINT hive_votes_ux1 DO
UPDATE
......
......@@ -299,10 +299,10 @@ async def _get_props_lite(db):
return dict(
time=raw['time'], #*
sbd_print_rate=raw['hbd_print_rate'], # TODO: rename this key to hbd_ after 0.24
sbd_interest_rate=raw['hbd_interest_rate'], # TODO: rename this key to hbd_ after 0.24
hbd_print_rate=raw['hbd_print_rate'],
hbd_interest_rate=raw['hbd_interest_rate'],
head_block_number=raw['head_block_number'], #*
total_vesting_shares=raw['total_vesting_shares'],
total_vesting_fund_steem=raw['total_vesting_fund_hive'],
total_vesting_fund_hive=raw['total_vesting_fund_hive'],
last_irreversible_block_num=raw['last_irreversible_block_num'], #*
)
......@@ -216,7 +216,7 @@ async def find_votes(context, params: dict, votes_presentation = VotesPresentati
hive_votes_accounts_permlinks_view
WHERE
author = :author AND permlink = :permlink
ORDER BY id
ORDER BY voter_id
"""
ret = []
......
......@@ -86,7 +86,7 @@ class HttpClient(object):
get_block='block_api',
get_accounts='condenser_api',
get_order_book='condenser_api',
get_feed_history='condenser_api',
get_feed_history='database_api',
get_dynamic_global_properties='database_api',
get_comment_pending_payouts='database_api',
get_ops_in_block='account_history_api',
......
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