Commit 73f9d267 authored by Bartek Wrona's avatar Bartek Wrona
Browse files

Merge branch 'community_pagination' into 'develop'

community pagination fix

See merge request !488
parents 354569d1 4fe21b90
DROP FUNCTION IF EXISTS bridge_get_ranked_post_pinned_for_community;
CREATE FUNCTION bridge_get_ranked_post_pinned_for_community( in _community VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
CREATE FUNCTION bridge_get_ranked_post_pinned_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR)
RETURNS SETOF bridge_api_post
AS
$function$
DECLARE
__observer_id INT;
__post_id INT;
BEGIN
__observer_id = find_account_id( _observer, True );
RETURN QUERY
IF _author != '' AND _permlink != '' THEN
__post_id = find_comment_id( _author, _permlink, True );
END IF;
RETURN QUERY
WITH pinned AS
(
SELECT
......@@ -17,6 +22,7 @@ BEGIN
JOIN hive_communities hc ON hc.id = hp.community_id
LEFT OUTER JOIN blacklisted_by_observer_view blacklist ON (blacklist.observer_id = __observer_id AND blacklist.blacklisted_id = hp.author_id)
WHERE hc.name = _community AND hp.is_pinned
AND ((_author = '' AND _permlink = '') OR hp.id < __post_id)
AND (NOT EXISTS (SELECT 1 FROM muted_accounts_by_id_view WHERE observer_id = __observer_id AND muted_id = hp.author_id))
ORDER BY hp.id DESC
LIMIT _limit
......
......@@ -110,9 +110,8 @@ async def _get_ranked_posts_for_communities( db, sort:str, community, start_auth
async def execute_community_query(db, sql, limit):
return await db.query_all(sql, community=community, author=start_author, permlink=start_permlink, limit=limit, observer=observer )
pinned_sql = "SELECT * FROM bridge_get_ranked_post_pinned_for_community( (:community)::VARCHAR, (:limit)::SMALLINT, (:observer)::VARCHAR )"
# missing paging which results in inability to get all pinned posts
# and/or causes the same posts to be on each page (depending on limit and number of pinned)
pinned_sql = "SELECT * FROM bridge_get_ranked_post_pinned_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, (:observer)::VARCHAR )"
if sort == 'hot':
sql = "SELECT * FROM bridge_get_ranked_post_by_hot_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, (:observer)::VARCHAR )"
return await execute_community_query(db, sql, limit)
......
......@@ -1363,6 +1363,150 @@
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost1",
"title": "Pinpost 1",
"body": "hello from pinned post 1",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost2",
"title": "Pinpost 2",
"body": "hello from pinned post 2",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost3",
"title": "Pinpost 3",
"body": "hello from pinned post 3",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost4",
"title": "Pinpost 4",
"body": "hello from pinned post 4",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost5",
"title": "Pinpost 5",
"body": "hello from pinned post 5",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost6",
"title": "Pinpost 6",
"body": "hello from pinned post 6",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost7",
"title": "Pinpost 7",
"body": "hello from pinned post 7",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost8",
"title": "Pinpost 8",
"body": "hello from pinned post 8",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost9",
"title": "Pinpost 9",
"body": "hello from pinned post 9",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost10",
"title": "Pinpost 10",
"body": "hello from pinned post 10",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost11",
"title": "Pinpost 11",
"body": "hello from pinned post 11",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
"parent_author": "",
"parent_permlink": "hive-135485",
"author": "test-creator",
"permlink": "pinpost12",
"title": "Pinpost 12",
"body": "hello from pinned post 12",
"json_metadata": "{}"
}
},
{
"type": "comment_operation",
"value": {
......@@ -1408,6 +1552,138 @@
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinned-post\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost1\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost2\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost3\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost4\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost5\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost6\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost7\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost8\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost9\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost10\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost11\"}]"
}
},
{
"type": "custom_json_operation",
"value": {
"required_auths": [],
"required_posting_auths": [
"test-safari"
],
"id": "community",
"json": "[\"pinPost\",{\"community\":\"hive-135485\",\"account\":\"test-creator\",\"permlink\":\"pinpost12\"}]"
}
}
]
}
......
Subproject commit 0730539dc6d6b90cd04e2e9d91334c4916b051ea
Subproject commit 41a90cf6a1b1da25dd2382df286ab290244606a2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment