Skip to content
Snippets Groups Projects
Commit dca9be85 authored by Gandalf's avatar Gandalf
Browse files

[JES] Fix get_ranked_posts viewing 'my' communities. I was joining on author...

[JES] Fix get_ranked_posts viewing 'my' communities. I was joining on author instead of observer which was giving incorrect results
parent 2f801dd9
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
......@@ -183,26 +183,28 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='',
elif tag == 'my':
if start_author and start_permlink:
if sort == 'trending':
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id )
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id =
(SELECT id FROM hive_accounts WHERE name = :observer) )
AND hive_posts_cache.sc_trend <= (SELECT sc_trend FROM hive_posts_cache WHERE permlink = :permlink AND author = :author )
AND hive_posts_cache.post_id != (SELECT post_id FROM hive_posts_cache WHERE permlink = :permlink AND author = :author) """
elif sort == 'hot':
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id)
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id = hive_accounts.id)
AND hive_posts_cache.sc_hot <= (SELECT sc_hot FROM hive_posts_cache WHERE permlink = :permlink AND author = :author)
AND hive_posts_cache.post_id != (SELECT post_id FROM hive_posts_cache WHERE permlink = :permlink AND author = :author) """
elif sort == 'created':
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id )
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id = hive_accounts.id )
AND hive_posts_cache.post_id < (SELECT post_id FROM hive_posts_cache WHERE permlink = :permlink AND author = :author ) """
elif sort == 'promoted':
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id )
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id = hive_accounts.id )
AND hive_posts_cache.promoted <= (SELECT promoted FROM hive_posts_cache WHERE permlink = :permlink AND author = :author )
AND hive_posts_cache.post_id != (SELECT post_id FROM hive_posts_cache WHERE permlink = :permlink AND author = :author) """
else:
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id )
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id = hive_accounts.id )
AND hive_posts_cache.payout <= (SELECT payout FROM hive_posts_cache WHERE permlink = :permlink AND author = :author)
AND hive_posts_cache.post_id != (SELECT post_id FROM hive_posts_cache WHERE permlink = :permlink AND author = :author ) """
else:
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_roles WHERE account_id = hive_accounts.id ) """
sql = sql % """ AND hive_posts_cache.community_id IN (SELECT community_id FROM hive_subscriptions WHERE account_id =
(SELECT id FROm hive_accounts WHERE name = :observer) ) """
elif tag[:5] == 'hive-':
if start_author and start_permlink:
if sort == 'trending':
......@@ -258,7 +260,10 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='',
else:
sql = sql % """ AND hive_posts_cache.post_id IN (SELECT post_id FROM hive_post_tags WHERE tag = :tag)"""
sql_result = await db.query_all(sql, author=start_author, limit=limit, tag=tag, permlink=start_permlink, community_name=tag)
if not observer:
observer = '';
sql_result = await db.query_all(sql, author=start_author, limit=limit, tag=tag, permlink=start_permlink, community_name=tag, observer=observer)
posts = []
for row in sql_result:
post = _condenser_post_object(row)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment