Skip to content
Snippets Groups Projects

Draft: Refactor get_ranked_posts.sql to add a CTE to ensure posts get filtered by...

Closed Dan Notestein requested to merge speedup-ranked-posts into develop
3 unresolved threads
Files
4
@@ -17,14 +17,18 @@ BEGIN
_permlink = hivemind_postgrest_utilities.parse_string_argument_from_json(_params, _json_is_object, 'permlink', 1, True);
_account_id = hivemind_postgrest_utilities.find_account_id( hivemind_postgrest_utilities.valid_account(_author, False), True );
_post_id = hivemind_postgrest_utilities.find_comment_id( _author, hivemind_postgrest_utilities.valid_permlink(_permlink, False), True );
_result = jsonb_agg( -- condenser_api_get_reblogged_by
(SELECT ha.name FROM hivemind_app.hive_accounts ha JOIN hivemind_app.hive_feed_cache hfc ON ha.id = hfc.account_id WHERE hfc.post_id = _post_id AND hfc.account_id <> _account_id ORDER BY ha.name)
);
SELECT
jsonb_agg(ha.name ORDER BY ha.name) INTO _result
FROM
hivemind_app.hive_accounts ha
JOIN hivemind_app.hive_feed_cache hfc ON ha.id = hfc.account_id
WHERE
hfc.post_id = _post_id
AND hfc.account_id <> _account_id;
IF _result IS NULL OR jsonb_typeof(_result->0) = 'null' THEN
_result = '[]'::jsonb;
END IF;
RETURN _result;
END;
$$
Loading