From 931f34d38ace5407f8afdc6736bd26e1648a9be3 Mon Sep 17 00:00:00 2001 From: Dariusz Kedzierski <dkedzierski@syncad.com> Date: Wed, 24 Jun 2020 14:42:45 +0200 Subject: [PATCH] CRITICAL FIX: escaping routine was invalid causing empty values in hive_post_data. Body for get_active_votes --- hive/indexer/post_data_cache.py | 6 ++++-- hive/server/tags_api/methods.py | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/hive/indexer/post_data_cache.py b/hive/indexer/post_data_cache.py index 65a40997e..35c6ba169 100644 --- a/hive/indexer/post_data_cache.py +++ b/hive/indexer/post_data_cache.py @@ -5,9 +5,11 @@ log = logging.getLogger(__name__) DB = Db.instance() def escape_characters(text): - characters = ["'", "\\", "_", "%"] + characters = ["'", "_", "%"] + ret = str(text) for ch in characters: - text = text.replace(ch, "\\" + ch) + ret = ret.replace(ch, "\\" + ch) + return ret class PostDataCache(object): """ Procides cache for DB operations on post data table in order to speed up initial sync """ diff --git a/hive/server/tags_api/methods.py b/hive/server/tags_api/methods.py index db846c5f7..3f20f52ed 100644 --- a/hive/server/tags_api/methods.py +++ b/hive/server/tags_api/methods.py @@ -3,13 +3,32 @@ from hive.server.common.helpers import ( valid_account, valid_permlink) + @return_error_info async def get_active_votes(context, author: str, permlink: str): """ Returns all votes for the given post. """ valid_account(author) valid_permlink(permlink) - # TODO: body - raise NotImplementedError() + db = context['db'] + 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 async def get_tags_used_by_author(context, author: str): -- GitLab