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

[JES] Add a limit on the get_account_posts call to only return 2000. There are...

[JES] Add a limit on the get_account_posts call to only return 2000. There are some posts out there with thousands upon thousands of comments and those seem to freeze up the hivemind server. This should help avoid that
parent 813f9460
No related branches found
No related tags found
3 merge requests!456Release candidate v1 24,!230Setup monitoring with pghero,!135Enable postgres monitoring on CI server
...@@ -23,24 +23,32 @@ async def get_discussion(context, author, permlink, observer=None): ...@@ -23,24 +23,32 @@ async def get_discussion(context, author, permlink, observer=None):
permlink = valid_permlink(permlink) permlink = valid_permlink(permlink)
sql = """ sql = """
---get_discussion WITH RECURSIVE child_posts (id, parent_id) AS (
WITH RECURSIVE child_posts AS ( SELECT id, parent_id
SELECT id, parent_id FROM hive_posts WHERE author = :author AND permlink = :permlink AND NOT is_deleted AND NOT is_muted FROM hive_posts hp
UNION ALL WHERE hp.author = 'et42k' AND hp.permlink = 'iqx-hashtag'
SELECT children.id, children.parent_id FROM hive_posts children JOIN child_posts ON (children.parent_id = child_posts.id) AND NOT hp.is_deleted AND NOT hp.is_muted
WHERE NOT children.is_deleted AND NOT children.is_muted UNION ALL
) SELECT children.id, children.parent_id
SELECT child_posts.id, child_posts.parent_id, hive_posts_cache.post_id, hive_posts_cache.author, hive_posts_cache.permlink, FROM hive_posts children
hive_posts_cache.title, hive_posts_cache.body, hive_posts_cache.category, hive_posts_cache.depth, INNER JOIN child_posts ON (children.parent_id = child_posts.id)
hive_posts_cache.promoted, hive_posts_cache.payout, hive_posts_cache.payout_at, WHERE NOT children.is_deleted AND NOT children.is_muted
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, SELECT child_posts.id, child_posts.parent_id, hive_posts_cache.post_id, hive_posts_cache.author, hive_posts_cache.permlink,
hive_posts_cache.raw_json, hive_posts_cache.json, hive_accounts.reputation AS author_rep, hive_posts_cache.title, hive_posts_cache.body, hive_posts_cache.category, hive_posts_cache.depth,
hive_posts_cache.is_hidden AS is_hidden, hive_posts_cache.is_grayed AS is_grayed, hive_posts_cache.promoted, hive_posts_cache.payout, hive_posts_cache.payout_at,
hive_posts_cache.total_votes AS total_votes, hive_posts_cache.flag_weight AS flag_weight, hive_posts_cache.is_paidout, hive_posts_cache.children, hive_posts_cache.votes,
hive_posts_cache.sc_trend AS sc_trend, hive_accounts.id AS acct_author_id hive_posts_cache.created_at, hive_posts_cache.updated_at, hive_posts_cache.rshares,
FROM child_posts JOIN hive_posts_cache ON (child_posts.id = hive_posts_cache.post_id) hive_posts_cache.raw_json, hive_posts_cache.json, hive_accounts.reputation AS author_rep,
JOIN hive_accounts ON (hive_posts_cache.author = hive_accounts.name) 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 blacklists_for_user = None
......
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