Skip to content
Snippets Groups Projects
Commit 931f34d3 authored by Dariusz Kędzierski's avatar Dariusz Kędzierski
Browse files

CRITICAL FIX: escaping routine was invalid causing empty values in...

CRITICAL FIX: escaping routine was invalid causing empty values in hive_post_data. Body for get_active_votes
parent 5e922bc3
No related branches found
No related tags found
5 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!135Enable postgres monitoring on CI server,!16Dk issue 3 concurrent block query rebase,!15Dk issue 3 concurrent block query
...@@ -5,9 +5,11 @@ log = logging.getLogger(__name__) ...@@ -5,9 +5,11 @@ log = logging.getLogger(__name__)
DB = Db.instance() DB = Db.instance()
def escape_characters(text): def escape_characters(text):
characters = ["'", "\\", "_", "%"] characters = ["'", "_", "%"]
ret = str(text)
for ch in characters: for ch in characters:
text = text.replace(ch, "\\" + ch) ret = ret.replace(ch, "\\" + ch)
return ret
class PostDataCache(object): class PostDataCache(object):
""" Procides cache for DB operations on post data table in order to speed up initial sync """ """ Procides cache for DB operations on post data table in order to speed up initial sync """
......
...@@ -3,13 +3,32 @@ from hive.server.common.helpers import ( ...@@ -3,13 +3,32 @@ from hive.server.common.helpers import (
valid_account, valid_account,
valid_permlink) valid_permlink)
@return_error_info @return_error_info
async def get_active_votes(context, author: str, permlink: str): async def get_active_votes(context, author: str, permlink: str):
""" Returns all votes for the given post. """ """ Returns all votes for the given post. """
valid_account(author) valid_account(author)
valid_permlink(permlink) valid_permlink(permlink)
# TODO: body db = context['db']
raise NotImplementedError() sql = """
SELECT
ha_v.name as voter
ha_a.name as author
hpd.permlink as permlink
weight
rshares
vote_percent
last_update
num_changes
FROM
hive_votes hv
INNER JOIN hive_accounts ha_v ON ha_v.id = hv.voter_id
INNER JOIN hive_accounts ha_a ON ha_a.id = hv.author_id
INNER JOIN hive_permlink_data hpd ON hpd.id = hv.permlink_id
WHERE ha_a.name = :author AND hpd.permlink = :permlink
"""
ret = await db.query_all(sql, author=author, permlink=permlink)
return ret
@return_error_info @return_error_info
async def get_tags_used_by_author(context, author: str): async def get_tags_used_by_author(context, author: str):
......
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