diff --git a/hive/server/bridge_api/objects.py b/hive/server/bridge_api/objects.py index 204078ca11a7e7df5fa591c3561c670e71ff895f..64b845f93658ef9877ecee593c8a198f9f82d38e 100644 --- a/hive/server/bridge_api/objects.py +++ b/hive/server/bridge_api/objects.py @@ -233,7 +233,7 @@ def _condenser_post_object(row, truncate_body=0): post['url'] = row['url'] post['root_title'] = row['root_title'] - post['beneficiaries'] = json.loads(row['beneficiaries']) + post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] post['percent_steem_dollars'] = row['percent_steem_dollars'] diff --git a/hive/server/common/objects.py b/hive/server/common/objects.py index 65337e96cf6687b5ce411ad28b092e45eacceb9e..1e731d960d6f2520247bf56c4325e6b6a37d01e2 100644 --- a/hive/server/common/objects.py +++ b/hive/server/common/objects.py @@ -81,7 +81,7 @@ def condenser_post_object(row, truncate_body=0): post['url'] = row['url'] post['root_title'] = row['root_title'] - post['beneficiaries'] = json.loads(row['beneficiaries']) + post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] post['percent_steem_dollars'] = row['percent_steem_dollars'] diff --git a/hive/server/condenser_api/objects.py b/hive/server/condenser_api/objects.py index 838df98db0d7ba729ad302862fd1c8a645b871d8..71148d3c59bad168150b7e464d1e06fe95a7dc81 100644 --- a/hive/server/condenser_api/objects.py +++ b/hive/server/condenser_api/objects.py @@ -185,7 +185,7 @@ def _condenser_post_object(row, truncate_body=0): post['url'] = row['url'] post['root_title'] = row['root_title'] - post['beneficiaries'] = json.loads(row['beneficiaries']) + post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] post['percent_steem_dollars'] = row['percent_steem_dollars'] diff --git a/hive/server/database_api/methods.py b/hive/server/database_api/methods.py index 3fcc71caeddc0f230e7d0712ffe02122fa57f301..6bf3e7671d3a297c9736a9cc9634dd58118053c4 100644 --- a/hive/server/database_api/methods.py +++ b/hive/server/database_api/methods.py @@ -4,7 +4,7 @@ from hive.server.common.objects import condenser_post_object async def get_post_id_by_author_and_permlink(db, author: str, permlink: str, limit: int): """Return post ids for given author and permlink""" - sql = """SELECT post_id FROM hive_posts_cache WHERE author >= :author AND permlink >= :permlink ORDER BY author ASC, permlink ASC, post_id ASC LIMIT :limit""" + sql = """SELECT post_id FROM hive_posts_cache WHERE author = :author AND permlink = :permlink ORDER BY author ASC, permlink ASC, post_id ASC LIMIT :limit""" result = await db.query_row(sql, author=author, permlink=permlink, limit=limit) return result.post_id @@ -32,7 +32,7 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM hive_posts_cache WHERE payout_at >= :start AND post_id >= :post_id ORDER BY payout_at ASC, post_id ASC LIMIT :limit""" result = await db.query_all(sql, start=start[0], limit=limit, post_id=post_id) for row in result: @@ -45,8 +45,8 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title - FROM hive_posts_cache WHERE author >= :author AND permlink >= :permlink ORDER BY author ASC, permlink ASC, post_id ASC LIMIT :limit""" + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title + FROM hive_posts_cache WHERE author >= :author AND permlink >= :permlink ORDER BY author ASC, permlink ASC LIMIT :limit""" result = await db.query_all(sql, author=start[0], permlink=start[1], limit=limit) for row in result: comments.append(condenser_post_object(dict(row))) @@ -59,7 +59,7 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM get_rows_by_root(:root_author, :root_permlink, :child_author, :child_permlink) ORDER BY post_id ASC LIMIT :limit""" result = await db.query_all(sql, root_author=start[0], root_permlink=start[1], child_author=start[2], child_permlink=start[3], limit=limit) for row in result: @@ -73,7 +73,7 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM get_rows_by_parent(:parent_author, :parent_permlink, :child_author, :child_permlink) LIMIT :limit""" result = await db.query_all(sql, parent_author=start[0], parent_permlink=start[1], child_author=start[2], child_permlink=start[3], limit=limit) for row in result: @@ -94,7 +94,7 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM hive_posts_cache WHERE parent_author >= :parent_author AND updated_at >= :updated_at AND post_id >= :post_id ORDER BY parent_author ASC, updated_at ASC, post_id ASC LIMIT :limit""" result = await db.query_all(sql, parent_author=start[0], updated_at=start[1], post_id=post_id, limit=limit) for row in result: @@ -116,7 +116,7 @@ async def list_comments(context, start: list, limit: int, order: str): is_hidden, is_grayed, total_votes, flag_weight, legacy_id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, percent_steem_dollars, - allow_replies, allow_votes, allow_curation_rewards, url, root_title + allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM hive_posts_cache WHERE author >= :author AND updated_at >= :updated_at AND post_id >= :post_id ORDER BY parent_author ASC, updated_at ASC, post_id ASC LIMIT :limit""" result = await db.query_all(sql, author=start[0], updated_at=start[1], post_id=post_id, limit=limit) for row in result: diff --git a/scripts/update_hivemind_db.sql b/scripts/update_hivemind_db.sql index 05e0201ee2441e00096a2344176aaf9aa44aa753..deda2a006ffee5ed64b59255486b26b40f62097e 100644 --- a/scripts/update_hivemind_db.sql +++ b/scripts/update_hivemind_db.sql @@ -88,6 +88,7 @@ DO $$ -- Creating indexes RAISE NOTICE 'Creating author_permlink_idx'; CREATE INDEX IF NOT EXISTS author_permlink_idx ON hive_posts_cache (author ASC, permlink ASC); + CREATE INDEX IF NOT EXISTS permlink_author_idx ON hive_posts_cache (permlink ASC, author ASC); RAISE NOTICE 'Creating root_author_permlink_idx'; CREATE INDEX IF NOT EXISTS root_author_permlink_idx ON hive_posts_cache (root_author ASC, root_permlink ASC); RAISE NOTICE 'Creating parent_permlink_idx'; @@ -109,7 +110,7 @@ DO $$ child_row hive_posts_cache; query_count INT := 0; BEGIN - FOR root_row IN SELECT * FROM hive_posts_cache WHERE author >= root_a AND permlink >= root_p ORDER BY post_id ASC, author ASC, permlink ASC + FOR root_row IN SELECT * FROM hive_posts_cache WHERE author = root_a AND permlink = root_p ORDER BY post_id ASC, author ASC, permlink ASC LOOP EXIT WHEN query_count >= query_limit; FOR child_row IN SELECT * FROM hive_posts_cache WHERE author >= child_a AND permlink >= child_p AND root_author = root_row.root_author AND root_permlink = root_row.root_permlink ORDER BY post_id ASC, author ASC, permlink ASC