diff --git a/hive/server/bridge_api/thread.py b/hive/server/bridge_api/thread.py index 570d846137d7ed9c21180424c7fb058b2cb6ab6d..0a07f671f82c6858b0e7d411877dfe4af0976e85 100644 --- a/hive/server/bridge_api/thread.py +++ b/hive/server/bridge_api/thread.py @@ -23,24 +23,32 @@ async def get_discussion(context, author, permlink, observer=None): permlink = valid_permlink(permlink) sql = """ - ---get_discussion - WITH RECURSIVE child_posts AS ( - SELECT id, parent_id FROM hive_posts WHERE author = :author AND permlink = :permlink AND NOT is_deleted AND NOT is_muted - UNION ALL - SELECT children.id, children.parent_id FROM hive_posts children JOIN child_posts ON (children.parent_id = child_posts.id) - WHERE NOT children.is_deleted AND NOT children.is_muted - ) - SELECT child_posts.id, child_posts.parent_id, hive_posts_cache.post_id, hive_posts_cache.author, hive_posts_cache.permlink, - hive_posts_cache.title, hive_posts_cache.body, hive_posts_cache.category, hive_posts_cache.depth, - hive_posts_cache.promoted, hive_posts_cache.payout, hive_posts_cache.payout_at, - hive_posts_cache.is_paidout, hive_posts_cache.children, hive_posts_cache.votes, - hive_posts_cache.created_at, hive_posts_cache.updated_at, hive_posts_cache.rshares, - hive_posts_cache.raw_json, hive_posts_cache.json, hive_accounts.reputation AS author_rep, - hive_posts_cache.is_hidden AS is_hidden, hive_posts_cache.is_grayed AS is_grayed, - hive_posts_cache.total_votes AS total_votes, hive_posts_cache.flag_weight AS flag_weight, - hive_posts_cache.sc_trend AS sc_trend, hive_accounts.id AS acct_author_id - FROM child_posts JOIN hive_posts_cache ON (child_posts.id = hive_posts_cache.post_id) - JOIN hive_accounts ON (hive_posts_cache.author = hive_accounts.name) + WITH RECURSIVE child_posts (id, parent_id) AS ( + SELECT id, parent_id + FROM hive_posts hp + WHERE hp.author = 'et42k' AND hp.permlink = 'iqx-hashtag' + AND NOT hp.is_deleted AND NOT hp.is_muted + UNION ALL + SELECT children.id, children.parent_id + FROM hive_posts children + INNER JOIN child_posts ON (children.parent_id = child_posts.id) + WHERE NOT children.is_deleted AND NOT children.is_muted + ) + SELECT child_posts.id, child_posts.parent_id, hive_posts_cache.post_id, hive_posts_cache.author, hive_posts_cache.permlink, + hive_posts_cache.title, hive_posts_cache.body, hive_posts_cache.category, hive_posts_cache.depth, + hive_posts_cache.promoted, hive_posts_cache.payout, hive_posts_cache.payout_at, + hive_posts_cache.is_paidout, hive_posts_cache.children, hive_posts_cache.votes, + hive_posts_cache.created_at, hive_posts_cache.updated_at, hive_posts_cache.rshares, + hive_posts_cache.raw_json, hive_posts_cache.json, hive_accounts.reputation AS author_rep, + hive_posts_cache.is_hidden AS is_hidden, hive_posts_cache.is_grayed AS is_grayed, + hive_posts_cache.total_votes AS total_votes, hive_posts_cache.flag_weight AS flag_weight, + hive_posts_cache.sc_trend AS sc_trend, hive_accounts.id AS acct_author_id + FROM child_posts + inner JOIN hive_posts_cache ON (child_posts.id = hive_posts_cache.post_id) + -- inner JOIN hive_posts ON (hive_posts_cache.post_id = hive_posts.id) + inner JOIN hive_accounts ON (hive_posts_cache.author = hive_accounts.name) + -- WHERE NOT hive_posts.is_deleted AND NOT hive_posts.is_muted + limit 2000 """ blacklists_for_user = None