Skip to content
Snippets Groups Projects
Commit 142a662e authored by Jason Salyers's avatar Jason Salyers
Browse files

[JES] Initial test of adding observer to additional bridge calls before I go changing all of them

parent 2021370c
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!370Jsalyers muting at sql level
This commit is part of merge request !370. Comments created here will be created in the context of that merge request.
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created;
CREATE FUNCTION bridge_get_ranked_post_by_created( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_created( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -52,6 +52,7 @@ BEGIN ...@@ -52,6 +52,7 @@ BEGIN
FROM hive_posts hp1 FROM hive_posts hp1
JOIN hive_accounts_view ha ON hp1.author_id = ha.id JOIN hive_accounts_view ha ON hp1.author_id = ha.id
WHERE hp1.counter_deleted = 0 AND hp1.depth = 0 AND NOT ha.is_grayed AND ( __post_id = 0 OR hp1.id < __post_id ) WHERE hp1.counter_deleted = 0 AND hp1.depth = 0 AND NOT ha.is_grayed AND ( __post_id = 0 OR hp1.id < __post_id )
AND (CASE WHEN _observer <> '' THEN hp.aouthor NOT IN (SELECT muted FROM muted_accounts_view WHERE observer = _observer) ELSE True END)
ORDER BY hp1.id DESC ORDER BY hp1.id DESC
LIMIT _limit LIMIT _limit
) as created ) as created
......
...@@ -186,7 +186,7 @@ async def _get_ranked_posts_for_tag( db, sort:str, tag, start_author:str, start_ ...@@ -186,7 +186,7 @@ async def _get_ranked_posts_for_tag( db, sort:str, tag, start_author:str, start_
assert False, "Unknown sort order" assert False, "Unknown sort order"
@return_error_info @return_error_info
async def _get_ranked_posts_for_all( db, sort:str, start_author:str, start_permlink:str, limit): async def _get_ranked_posts_for_all( db, sort:str, start_author:str, start_permlink:str, limit, observer:str=None):
async def execute_query(db, sql, limit): async def execute_query(db, sql, limit):
return await db.query_all(sql, author=start_author, permlink=start_permlink, limit=limit ) return await db.query_all(sql, author=start_author, permlink=start_permlink, limit=limit )
...@@ -195,8 +195,8 @@ async def _get_ranked_posts_for_all( db, sort:str, start_author:str, start_perml ...@@ -195,8 +195,8 @@ async def _get_ranked_posts_for_all( db, sort:str, start_author:str, start_perml
return await execute_query(db, sql, limit) return await execute_query(db, sql, limit)
if sort == 'created': if sort == 'created':
sql = "SELECT * FROM bridge_get_ranked_post_by_created( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )" sql = "SELECT * FROM bridge_get_ranked_post_by_created( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, (:observer)::VARCHAR )"
return await execute_query(db, sql, limit) return await execute_query(db, sql, limit, observer)
if sort == 'hot': if sort == 'hot':
sql = "SELECT * FROM bridge_get_ranked_post_by_hot( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )" sql = "SELECT * FROM bridge_get_ranked_post_by_hot( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
...@@ -259,7 +259,7 @@ async def get_ranked_posts(context, sort:str, start_author:str='', start_permlin ...@@ -259,7 +259,7 @@ async def get_ranked_posts(context, sort:str, start_author:str='', start_permlin
result = await _get_ranked_posts_for_tag(db, sort, tag, start_author, start_permlink, limit) result = await _get_ranked_posts_for_tag(db, sort, tag, start_author, start_permlink, limit)
return await process_query_results(result) return await process_query_results(result)
result = await _get_ranked_posts_for_all(db, sort, start_author, start_permlink, limit) result = await _get_ranked_posts_for_all(db, sort, start_author, start_permlink, limit, observer)
return await process_query_results(result) return await process_query_results(result)
@return_error_info @return_error_info
......
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