diff --git a/hive/db/sql_scripts/bridge_get_ranked_post_for_observer_communities.sql b/hive/db/sql_scripts/bridge_get_ranked_post_for_observer_communities.sql index d6a0d8ffa0e4dfcfa5142d5bf1800bec4ab89c15..7e836ba765e6fa7fd40f1b95fb500e1a04467a46 100644 --- a/hive/db/sql_scripts/bridge_get_ranked_post_for_observer_communities.sql +++ b/hive/db/sql_scripts/bridge_get_ranked_post_for_observer_communities.sql @@ -340,6 +340,7 @@ BEGIN IF __post_id <> 0 THEN SELECT hp.sc_trend INTO __trending_limit FROM hive_posts hp WHERE hp.id = __post_id; END IF; + __account_id = find_account_id( _observer, True ); RETURN QUERY SELECT hp.id, hp.author, @@ -385,9 +386,8 @@ BEGIN FROM hive_posts hp1 JOIN hive_subscriptions hs ON hp1.community_id = hs.community_id - JOIN hive_accounts ha ON ha.id = hs.account_id WHERE - ha.name = _observer AND hp1.counter_deleted = 0 AND NOT hp1.is_paidout AND hp1.depth = 0 + hs.account_id = __account_id AND hp1.counter_deleted = 0 AND NOT hp1.is_paidout AND hp1.depth = 0 AND ( __post_id = 0 OR hp1.sc_trend < __trending_limit OR ( hp1.sc_trend = __trending_limit AND hp1.id < __post_id ) ) ORDER BY hp1.sc_trend DESC, hp1.id DESC LIMIT _limit diff --git a/hive/db/sql_scripts/condenser_get_account_reputations.sql b/hive/db/sql_scripts/condenser_get_account_reputations.sql index 5a9a8a33ce13bbcfe84c9052a88e7c63a29ebd42..e390998cad46f7a723337f9b80a8dc9739d8cee4 100644 --- a/hive/db/sql_scripts/condenser_get_account_reputations.sql +++ b/hive/db/sql_scripts/condenser_get_account_reputations.sql @@ -2,7 +2,6 @@ DROP FUNCTION IF EXISTS condenser_get_account_reputations; CREATE OR REPLACE FUNCTION condenser_get_account_reputations( in _account_lower_bound VARCHAR, - in _without_lower_bound BOOLEAN, in _limit INTEGER ) RETURNS TABLE @@ -19,7 +18,7 @@ BEGIN RETURN QUERY SELECT ha.name, ha.reputation FROM hive_accounts ha - WHERE _without_lower_bound OR ( ha.name >= _account_lower_bound ) + WHERE ha.name >= _account_lower_bound AND ha.id != 0 -- don't include artificial empty account ORDER BY name LIMIT _limit; diff --git a/hive/server/bridge_api/methods.py b/hive/server/bridge_api/methods.py index d4a670ed5ea2baae6efccdad7440c59e1495f934..077c0cf8be6c9e4fa5faff45bb3281cde1b9743c 100644 --- a/hive/server/bridge_api/methods.py +++ b/hive/server/bridge_api/methods.py @@ -320,8 +320,6 @@ async def get_account_posts(context, sort:str, account:str, start_author:str='', posts.append(post) return posts - return await _get_posts(db, sort, account, start_author, start_permlink, limit, observer) - @return_error_info async def get_relationship_between_accounts(context, account1, account2, observer=None): diff --git a/hive/server/condenser_api/get_state.py b/hive/server/condenser_api/get_state.py index 663abb50dd23441c3cfe5b6206e96e78c05a50a0..d1b4eec2a9546e6c22e0a9b11516e091425c0ed0 100644 --- a/hive/server/condenser_api/get_state.py +++ b/hive/server/condenser_api/get_state.py @@ -11,7 +11,6 @@ from hive.server.common.mutes import Mutes from hive.server.condenser_api.objects import ( load_accounts, - _mute_votes, _condenser_post_object) from hive.server.common.helpers import ( ApiError, @@ -251,7 +250,6 @@ async def _load_discussion(db, author, permlink): if post['author'] not in muted_accounts: post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], muted_accounts) posts.append(post) parent_key = _ref_parent(post) diff --git a/hive/server/condenser_api/methods.py b/hive/server/condenser_api/methods.py index 610dbf5bc86ba23f131e76c5007e3a382845fc61..fedd8c81f19f11fbaf16404d9c925f84132b5c0d 100644 --- a/hive/server/condenser_api/methods.py +++ b/hive/server/condenser_api/methods.py @@ -2,7 +2,7 @@ from functools import wraps import hive.server.condenser_api.cursor as cursor -from hive.server.condenser_api.objects import _mute_votes, _condenser_post_object +from hive.server.condenser_api.objects import _condenser_post_object from hive.server.common.helpers import ( ApiError, return_error_info, @@ -13,7 +13,6 @@ from hive.server.common.helpers import ( valid_offset, valid_limit, valid_follow_type) -from hive.server.common.mutes import Mutes from hive.server.database_api.methods import find_votes_impl, VotesPresentation # pylint: disable=too-many-arguments,line-too-long,too-many-lines @@ -84,16 +83,18 @@ async def get_reblogged_by(context, author: str, permlink: str): valid_permlink(permlink)) @return_error_info -async def get_account_reputations(context, account_lower_bound: str = None, limit: int = None): +async def get_account_reputations(context, account_lower_bound: str = '', limit: int = 1000): db = context['db'] return await _get_account_reputations_impl(db, True, account_lower_bound, limit) async def _get_account_reputations_impl(db, fat_node_style, account_lower_bound, limit): """Enumerate account reputations.""" + if not account_lower_bound: + account_lower_bound = '' assert isinstance(account_lower_bound, str), "invalid account_lower_bound type" limit = valid_limit(limit, 1000, 1000) - sql = "SELECT * FROM condenser_get_account_reputations( '{}', {}, {} )".format( account_lower_bound, account_lower_bound is None, limit ) + sql = "SELECT * FROM condenser_get_account_reputations( (:start)::VARCHAR, :limit )" rows = await db.query_all(sql, start=account_lower_bound, limit=limit) if fat_node_style: return [dict(account=r[0], reputation=r[1]) for r in rows] @@ -121,11 +122,6 @@ async def _get_content_impl(db, fat_node_style, author: str, permlink: str, obse result = dict(result[0]) post = _condenser_post_object(result, 0, fat_node_style) post['active_votes'] = await find_votes_impl(db, author, permlink, VotesPresentation.ActiveVotes if fat_node_style else VotesPresentation.CondenserApi) - if not observer: - post['active_votes'] = _mute_votes(post['active_votes'], Mutes.all()) - else: - blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, {'db':db}) - post['active_votes'] = _mute_votes(post['active_votes'], blacklists_for_user.keys()) return post @@ -143,14 +139,11 @@ async def _get_content_replies_impl(db, fat_node_style, author: str, permlink: s sql = "SELECT * FROM condenser_get_content_replies(:author, :permlink)" result = await db.query_all(sql, author=author, permlink=permlink) - muted_accounts = Mutes.all() - posts = [] for row in result: row = dict(row) post = _condenser_post_object(row, get_content_additions=fat_node_style) post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.ActiveVotes if fat_node_style else VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], muted_accounts) posts.append(post) return posts @@ -238,11 +231,9 @@ async def get_posts_by_given_sort(context, sort: str, start_author: str = '', st sql_result = await db.query_all(sql, tag=tag, author=start_author, permlink=start_permlink, limit=limit ) - muted_accounts = Mutes.all() for row in sql_result: post = _condenser_post_object(row, truncate_body) post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], muted_accounts) posts.append(post) return posts @@ -313,8 +304,6 @@ async def get_discussions_by_blog(context, tag: str = None, start_author: str = row = dict(row) post = _condenser_post_object(row, truncate_body=truncate_body) post['active_votes'] = await find_votes_impl(db, post['author'], post['permlink'], VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], Mutes.all()) - #posts_by_id[row['post_id']] = post posts_by_id.append(post) return posts_by_id @@ -380,7 +369,6 @@ async def get_discussions_by_comments(context, start_author: str = None, start_p row = dict(row) post = _condenser_post_object(row, truncate_body=truncate_body) post['active_votes'] = await find_votes_impl(db, post['author'], post['permlink'], VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], Mutes.all()) posts.append(post) return posts @@ -445,15 +433,12 @@ async def get_blog(context, account: str, start_entry_id: int = 0, limit: int = sql = "SELECT * FROM condenser_get_blog(:account, :last, :limit)" result = await db.query_all(sql, account=account, last=start_entry_id, limit=limit) - muted_accounts = Mutes.all() out = [] for row in result: row = dict(row) post = _condenser_post_object(row) post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi) - post['active_votes'] = _mute_votes(post['active_votes'], muted_accounts) - out.append({"blog": account, "entry_id": row['entry_id'], "comment": post, diff --git a/hive/server/condenser_api/objects.py b/hive/server/condenser_api/objects.py index 49d0a69e45147e83059d687b3882f403dcf2d161..3d7c04a4562ad2955e131ac45a07bb96498f15d2 100644 --- a/hive/server/condenser_api/objects.py +++ b/hive/server/condenser_api/objects.py @@ -4,7 +4,6 @@ import logging import ujson as json from hive.utils.normalize import sbd_amount -from hive.server.common.mutes import Mutes from hive.server.common.helpers import json_date, get_hive_accounts_info_view_query_string from hive.server.database_api.methods import find_votes_impl, VotesPresentation from hive.utils.account import safe_db_profile_metadata @@ -19,11 +18,6 @@ async def load_accounts(db, names, lite = False): rows = await db.query_all(sql, names=tuple(names)) return [_condenser_account_object(row) for row in rows] -def _mute_votes(votes, muted_accounts): - if not muted_accounts: - return votes - return [v for v in votes if v['voter'] not in muted_accounts] - def _condenser_account_object(row): """Convert an internal account record into legacy-steemd style.""" #The member `vote_weight` from `hive_accounts` is removed, so currently the member `net_vesting_shares` is equals to zero. diff --git a/hive/server/follow_api/methods.py b/hive/server/follow_api/methods.py index 0f9add069984842fd9f5126b257e5b6710dc5633..9b41b98121799cb043245c28529920966e720782 100644 --- a/hive/server/follow_api/methods.py +++ b/hive/server/follow_api/methods.py @@ -2,7 +2,7 @@ from hive.server.condenser_api.methods import _get_account_reputations_impl from hive.server.common.helpers import return_error_info @return_error_info -async def get_account_reputations(context, account_lower_bound: str = None, limit: int = None): +async def get_account_reputations(context, account_lower_bound: str = '', limit: int = 1000): db = context['db'] return await _get_account_reputations_impl(db, False, account_lower_bound, limit) diff --git a/tests/tests_api b/tests/tests_api index 640732ad7ed82afe9da93183e62b71f7f67b2bd9..9af47554627a163d3ba2e50ebaf35fb74bdcfddf 160000 --- a/tests/tests_api +++ b/tests/tests_api @@ -1 +1 @@ -Subproject commit 640732ad7ed82afe9da93183e62b71f7f67b2bd9 +Subproject commit 9af47554627a163d3ba2e50ebaf35fb74bdcfddf