Skip to content
Snippets Groups Projects
Commit f16f90dd authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Changes incorporated by...

Changes incorporated by !297 to develop, prepared to deployed branch.
parent caa5c310
No related branches found
No related tags found
1 merge request!304Changes incorporated by...
......@@ -62,3 +62,65 @@ BEGIN
END
$function$
language plpgsql STABLE;
DROP FUNCTION IF EXISTS condenser_get_discussions_by_created_with_empty_tag;
CREATE FUNCTION condenser_get_discussions_by_created_with_empty_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT )
RETURNS SETOF bridge_api_post
AS
$function$
DECLARE
__post_id INT;
__community VARCHAR;
__category_id INT;
BEGIN
__post_id = find_comment_id( _author, _permlink, True );
__community = ( SELECT substring(_tag from '^hive-') );
__category_id = ( SELECT id FROM hive_category_data WHERE category = _tag );
RETURN QUERY SELECT
hp.id,
hp.author,
hp.parent_author,
hp.author_rep,
hp.root_title,
hp.beneficiaries,
hp.max_accepted_payout,
hp.percent_hbd,
hp.url,
hp.permlink,
hp.parent_permlink_or_category,
hp.title,
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
hp.is_paidout,
hp.children,
hp.votes,
hp.created_at,
hp.updated_at,
hp.rshares,
hp.abs_rshares,
hp.json,
hp.is_hidden,
hp.is_grayed,
hp.total_votes,
hp.sc_trend,
hp.role_title,
hp.community_title,
hp.role_id,
hp.is_pinned,
hp.curator_payout_value
FROM hive_posts_view hp
WHERE ( __post_id = 0 OR hp.id < __post_id )
AND ( ( __community IS NULL ) OR ( ( __community IS NOT NULL ) AND ( __category_id = 0 OR hp.category_id = __category_id ) ) )
ORDER BY hp.id DESC LIMIT _limit;
END
$function$
language plpgsql STABLE;
......@@ -62,3 +62,65 @@ BEGIN
END
$function$
language plpgsql STABLE;
DROP FUNCTION IF EXISTS condenser_get_discussions_by_hot_with_empty_tag;
CREATE FUNCTION condenser_get_discussions_by_hot_with_empty_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT )
RETURNS SETOF bridge_api_post
AS
$function$
DECLARE
__post_id INT;
__community VARCHAR;
__category_id INT;
BEGIN
__post_id = find_comment_id( _author, _permlink, True );
__community = ( SELECT substring(_tag from '^hive-') );
__category_id = ( SELECT id FROM hive_category_data WHERE category = _tag );
RETURN QUERY SELECT
hp.id,
hp.author,
hp.parent_author,
hp.author_rep,
hp.root_title,
hp.beneficiaries,
hp.max_accepted_payout,
hp.percent_hbd,
hp.url,
hp.permlink,
hp.parent_permlink_or_category,
hp.title,
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
hp.is_paidout,
hp.children,
hp.votes,
hp.created_at,
hp.updated_at,
hp.rshares,
hp.abs_rshares,
hp.json,
hp.is_hidden,
hp.is_grayed,
hp.total_votes,
hp.sc_trend,
hp.role_title,
hp.community_title,
hp.role_id,
hp.is_pinned,
hp.curator_payout_value
FROM hive_posts_view hp
WHERE hp.is_paidout = '0' AND ( __post_id = 0 OR hp.id < __post_id )
AND ( ( __community IS NULL ) OR ( ( __community IS NOT NULL ) AND ( ( __category_id = 0 OR hp.category_id = __category_id ) AND hp.depth = 0 ) ) )
ORDER BY hp.sc_hot DESC, hp.id DESC LIMIT _limit;
END
$function$
language plpgsql STABLE;
......@@ -62,3 +62,66 @@ BEGIN
END
$function$
language plpgsql STABLE;
DROP FUNCTION IF EXISTS condenser_get_discussions_by_promoted_with_empty_tag;
CREATE FUNCTION condenser_get_discussions_by_promoted_with_empty_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT )
RETURNS SETOF bridge_api_post
AS
$function$
DECLARE
__post_id INT;
__community VARCHAR;
__category_id INT;
BEGIN
__post_id = find_comment_id( _author, _permlink, True );
__community = ( SELECT substring(_tag from '^hive-') );
__category_id = ( SELECT id FROM hive_category_data WHERE category = _tag );
RETURN QUERY SELECT
hp.id,
hp.author,
hp.parent_author,
hp.author_rep,
hp.root_title,
hp.beneficiaries,
hp.max_accepted_payout,
hp.percent_hbd,
hp.url,
hp.permlink,
hp.parent_permlink_or_category,
hp.title,
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
hp.is_paidout,
hp.children,
hp.votes,
hp.created_at,
hp.updated_at,
hp.rshares,
hp.abs_rshares,
hp.json,
hp.is_hidden,
hp.is_grayed,
hp.total_votes,
hp.sc_trend,
hp.role_title,
hp.community_title,
hp.role_id,
hp.is_pinned,
hp.curator_payout_value
FROM hive_posts_view hp
INNER JOIN hive_post_tags hpt ON hpt.post_id = hp.id
WHERE hp.promoted > 0 AND ( __post_id = 0 OR hp.id < __post_id )
AND ( ( __community IS NULL ) OR ( ( __community IS NOT NULL ) AND ( __category_id = 0 OR hp.category_id = __category_id ) ) )
ORDER BY hp.promoted DESC, hp.id DESC LIMIT _limit;
END
$function$
language plpgsql STABLE;
......@@ -62,3 +62,65 @@ BEGIN
END
$function$
language plpgsql STABLE;
DROP FUNCTION IF EXISTS condenser_get_discussions_by_trending_with_empty_tag;
CREATE FUNCTION condenser_get_discussions_by_trending_with_empty_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT )
RETURNS SETOF bridge_api_post
AS
$function$
DECLARE
__post_id INT;
__community VARCHAR;
__category_id INT;
BEGIN
__post_id = find_comment_id( _author, _permlink, True );
__community = ( SELECT substring(_tag from '^hive-') );
__category_id = ( SELECT id FROM hive_category_data WHERE category = _tag );
RETURN QUERY SELECT
hp.id,
hp.author,
hp.parent_author,
hp.author_rep,
hp.root_title,
hp.beneficiaries,
hp.max_accepted_payout,
hp.percent_hbd,
hp.url,
hp.permlink,
hp.parent_permlink_or_category,
hp.title,
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
hp.is_paidout,
hp.children,
hp.votes,
hp.created_at,
hp.updated_at,
hp.rshares,
hp.abs_rshares,
hp.json,
hp.is_hidden,
hp.is_grayed,
hp.total_votes,
hp.sc_trend,
hp.role_title,
hp.community_title,
hp.role_id,
hp.is_pinned,
hp.curator_payout_value
FROM hive_posts_view hp
WHERE hp.is_paidout = '0' AND ( __post_id = 0 OR hp.id < __post_id )
AND ( ( __community IS NULL ) OR ( ( __community IS NOT NULL ) AND ( ( __category_id = 0 OR hp.category_id = __category_id ) AND hp.depth = 0 ) ) )
ORDER BY hp.sc_trend DESC, hp.id DESC LIMIT _limit;
END
$function$
language plpgsql STABLE;
......@@ -138,7 +138,7 @@ async def get_state(context, path: str):
sort = valid_sort(part[0])
tag = valid_tag(part[1].lower(), allow_empty=True)
pids = await get_posts_by_given_sort(context, sort, '', '', 20, tag)
state['content'] = _keyed_posts(await load_posts(db, pids))
state['content'] = _keyed_posts(pids)
state['discussion_idx'] = {tag: {sort: list(state['content'].keys())}}
state['tag_idx'] = {'trending': await get_top_trending_tags_summary(context)}
......
......@@ -247,13 +247,25 @@ async def get_posts_by_given_sort(context, sort: str, start_author: str = '', st
posts = []
if sort == 'created':
sql = "SELECT * FROM condenser_get_discussions_by_created( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_created_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_created( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'trending':
sql = "SELECT * FROM condenser_get_discussions_by_trending( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_trending_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_trending( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'hot':
sql = "SELECT * FROM condenser_get_discussions_by_hot( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_hot_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_hot( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'promoted':
sql = "SELECT * FROM condenser_get_discussions_by_promoted( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_promoted_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_promoted( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'post_by_payout':
sql = "SELECT * FROM condenser_get_post_discussions_by_payout( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'comment_by_payout':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment