Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • hive/hivemind
1 result
Show changes
Commits on Source (3)
Showing
with 32 additions and 24 deletions
......@@ -80,6 +80,7 @@ include:
"$CI_REGISTRY_IMAGE" \
--dot-env-filename=hivemind_image.env \
--dot-env-var-name=HIVEMIND_IMAGE
docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA"
if [[ -n "$CI_COMMIT_TAG" ]]; then
docker pull "$CI_REGISTRY_IMAGE/instance:$CI_COMMIT_SHORT_SHA"
docker tag "$CI_REGISTRY_IMAGE/instance:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY_IMAGE/instance:$CI_COMMIT_TAG"
......
......@@ -30,7 +30,7 @@ BEGIN
_limit = hivemind_postgrest_utilities.valid_number(_limit, 100, 1, 100, 'limit');
RETURN(
SELECT jsonb_agg(
SELECT jsonb_agg( -- bridge_api_account_notifications
jsonb_build_object(
'id', hive_notification_cache.id,
'type', hivemind_postgrest_utilities.get_notify_type_from_id(hive_notification_cache.type_id),
......@@ -93,6 +93,7 @@ BEGIN
ELSE hivemind_app.get_number_of_mentions_in_post( hnv.post_id )
END as mentions
) as hm
LIMIT _limit
) hive_notification_cache
);
END
......
......@@ -26,7 +26,7 @@ BEGIN
True);
RETURN (
SELECT to_jsonb(row) FROM (
SELECT to_jsonb(row) FROM ( -- bridge_api_get_community
SELECT
hc.id,
hc.name,
......
......@@ -28,7 +28,7 @@ BEGIN
RETURN COALESCE(
(
SELECT
SELECT -- bridge_api_get_discussion
jsonb_object_agg((row.author || '/' || row.permlink), hivemind_postgrest_utilities.create_bridge_post_object(row, 0, NULL, row.is_pinned, True, row.replies))
FROM (
SELECT
......
......@@ -41,7 +41,7 @@ BEGIN
IF _get_blacklists THEN
_result = (
WITH np AS (
WITH np AS ( -- bridge_api_get_follow_list with _get_blacklists
SELECT
ha.name,
hivemind_postgrest_utilities.extract_profile_metadata(ha.json_metadata, ha.posting_json_metadata)->'profile' AS profile
......@@ -63,7 +63,7 @@ BEGIN
);
ELSE
_result = (
SELECT jsonb_agg (
SELECT jsonb_agg ( -- bridge_api_get_follow_list without _get_blacklists
jsonb_build_object(
'name', row.name,
'blacklist_description', to_jsonb(''::TEXT),
......
......@@ -18,7 +18,7 @@ BEGIN
SELECT jsonb_agg(item)
INTO _result
FROM (
SELECT jsonb_build_array(
SELECT jsonb_build_array( -- bridge_api_get_payout_stats
COALESCE(hc.name, '@' || hpv.author),
COALESCE(hc.title, COALESCE('@' || hpv.author, 'Unknown')),
hpv.payout::float,
......
DROP FUNCTION IF EXISTS hivemind_endpoints.bridge_api_get_posts;
CREATE FUNCTION hivemind_endpoints.bridge_api_get_posts(IN _json_is_object BOOLEAN, IN _params JSONB)
DROP FUNCTION IF EXISTS hivemind_endpoints.bridge_api_get_post;
CREATE FUNCTION hivemind_endpoints.bridge_api_get_post(IN _json_is_object BOOLEAN, IN _params JSONB)
RETURNS JSONB
LANGUAGE 'plpgsql'
STABLE
......@@ -22,7 +22,7 @@ BEGIN
_post_id = hivemind_postgrest_utilities.find_comment_id( _author, _permlink, True);
RETURN (
SELECT hivemind_postgrest_utilities.create_bridge_post_object(row, 0, NULL, False, True) FROM (
SELECT hivemind_postgrest_utilities.create_bridge_post_object(row, 0, NULL, False, True) FROM ( -- bridge_api_get_post
SELECT
hp.id,
hp.author,
......
......@@ -23,7 +23,7 @@ BEGIN
'category', (CASE WHEN row.category IS NULL THEN '' ELSE row.category END),
'depth', row.depth
) FROM (
SELECT
SELECT -- bridge_api_get_posts_header
ha_a.name as author, hpd_p.permlink as permlink, hcd.category as category, depth
FROM
hivemind_app.hive_posts hp
......
......@@ -20,7 +20,7 @@ BEGIN
_observer := hivemind_postgrest_utilities.parse_string_argument_from_json(_params, _json_is_object, 'observer', 1, False);
PERFORM hivemind_postgrest_utilities.valid_account(_observer, True);
WITH main_communities AS (
WITH main_communities AS ( -- bridge_api_get_trending_topics
SELECT jsonb_build_array(
community_data->>0,
COALESCE(NULLIF(community_data->>1, ''), community_data->>0)
......
......@@ -18,7 +18,7 @@ BEGIN
True);
_result = (
SELECT jsonb_agg(
SELECT jsonb_agg( -- bridge_api_list_all_subscriptions
jsonb_build_array(row.name, row.title, row.role, row.role_title)
) FROM (
SELECT
......
......@@ -46,7 +46,7 @@ BEGIN
END IF;
_result = (
SELECT jsonb_agg(
SELECT jsonb_agg( -- bridge_api_list_community_roles
jsonb_build_array(row.name, row.role, row.title)
) FROM (
SELECT
......
......@@ -30,7 +30,7 @@ BEGIN
RETURN COALESCE(
(
SELECT jsonb_agg(jsonb_build_array(row.name, row.role, row.title, row.created_at)) FROM (
SELECT jsonb_agg(jsonb_build_array(row.name, row.role, row.title, row.created_at)) FROM ( -- bridge_api_list_subscribers
SELECT
ha.name,
hivemind_postgrest_utilities.get_role_name(COALESCE(hr.role_id,0)) AS role,
......
......@@ -36,7 +36,7 @@ BEGIN
RETURN (
SELECT jsonb_agg(to_jsonb(row)) FROM
(
WITH notifications AS
WITH notifications AS -- bridge_api_post_notifications
(
SELECT
hnv.id,
......@@ -88,6 +88,7 @@ BEGIN
END as mentions
) as hm
ORDER BY hnv.id DESC
LIMIT _limit
)
SELECT
notifications.id,
......@@ -104,6 +105,7 @@ BEGIN
END
) AS url
FROM notifications
LIMIT _limit
) row
);
END
......
......@@ -27,7 +27,7 @@ BEGIN
SELECT ha.lastread_at INTO _last_read_at FROM hivemind_app.hive_accounts ha WHERE ha.id = _account_id;
SELECT
COALESCE(
COALESCE( -- bridge_api_unread_notifications
(
SELECT hb.num
FROM hive.blocks_view hb -- very important for performance (originally it was a hivemind_app_blocks_view)
......
......@@ -21,7 +21,7 @@ BEGIN
IF _fat_node_style THEN
_result = (
SELECT jsonb_agg (
SELECT jsonb_agg ( -- condenser_api_get_account_reputations with fat node style
to_jsonb(row)
) FROM (
SELECT ha.name AS account, ha.reputation AS reputation
......@@ -33,7 +33,7 @@ BEGIN
);
ELSE
_result = jsonb_build_object('reputations', (
SELECT jsonb_agg (
SELECT jsonb_agg ( -- condenser_api_get_account_reputations without fat node style
to_jsonb(row)
) FROM (
SELECT ha.name AS name, ha.reputation AS reputation
......
......@@ -59,7 +59,7 @@ BEGIN
'reblogged_on', hivemind_postgrest_utilities.json_date(row.reblogged_at)
)
) FROM (
SELECT
SELECT -- condenser_api_get_blog_entries
blog.entry_id::INT,
ha.name as author,
hpd.permlink,
......@@ -85,10 +85,12 @@ BEGIN
JOIN hivemind_app.hive_accounts ha ON ha.id = hp.author_id
JOIN hivemind_app.hive_permlink_data hpd ON hpd.id = hp.permlink_id
ORDER BY blog.created_at DESC, blog.post_id DESC
LIMIT _limit
) row
);
ELSE
_result = (
-- condenser_api_get_blog
SELECT jsonb_agg(
jsonb_build_object(
'blog', _account,
......@@ -147,6 +149,7 @@ BEGIN
LATERAL hivemind_app.get_post_view_by_id(blog.post_id) hp
-- in python code order was ASC, but because we append new elements to array in reverse order, order is DESC here
ORDER BY blog.created_at DESC, blog.post_id DESC
LIMIT _limit
) row
);
END IF;
......
......@@ -23,7 +23,7 @@ BEGIN
SELECT jsonb_agg (
hivemind_postgrest_utilities.create_condenser_post_object(row, 0, _content_additions)
) FROM (
WITH replies AS
WITH replies AS -- condenser_api_get_content with replies
(
SELECT id
FROM hivemind_app.live_posts_comments_view hp
......@@ -81,7 +81,7 @@ BEGIN
RETURN COALESCE(_result, '[]'::jsonb);
ELSE
RETURN (
SELECT hivemind_postgrest_utilities.create_condenser_post_object(row, 0, _content_additions) FROM (
SELECT hivemind_postgrest_utilities.create_condenser_post_object(row, 0, _content_additions) FROM ( -- condenser_api_get_content without replies
SELECT
hp.id,
hp.author,
......
......@@ -46,7 +46,7 @@ BEGIN
SELECT jsonb_agg (
hivemind_postgrest_utilities.create_condenser_post_object(row, _truncate_body, False)
) FROM (
WITH blog_posts AS
WITH blog_posts AS -- condenser_api_get_discussions_by_author_before_date
(
SELECT
hp.id
......@@ -100,6 +100,7 @@ BEGIN
FROM blog_posts,
LATERAL hivemind_app.get_post_view_by_id(blog_posts.id) hp
ORDER BY hp.id DESC
LIMIT _limit
) row
);
......
......@@ -13,7 +13,7 @@ BEGIN
_account = hivemind_postgrest_utilities.parse_string_argument_from_json(_params, _json_is_object, 'account', 0, True);
_account_id = hivemind_postgrest_utilities.find_account_id(hivemind_postgrest_utilities.valid_account(_account, False), True);
RETURN (
SELECT to_jsonb(row) FROM (
SELECT to_jsonb(row) FROM ( -- condenser_api_get_follow_count
SELECT name AS account, ha.following AS following_count, ha.followers AS follower_count FROM hivemind_app.hive_accounts ha WHERE ha.id = _account_id
) row );
END;
......
......@@ -20,7 +20,7 @@ BEGIN
RETURN COALESCE(
(
SELECT jsonb_agg(
SELECT jsonb_agg( -- condenser_api_get_followers
jsonb_build_object(
'following', _params->'account',
'follower', row.name,
......