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 (101)
Showing
with 141 additions and 67 deletions
...@@ -3,7 +3,6 @@ stages: ...@@ -3,7 +3,6 @@ stages:
- data-supply - data-supply
- e2e-test - e2e-test
variables: variables:
PGPASSWORD: $HIVEMIND_POSTGRES_PASSWORD PGPASSWORD: $HIVEMIND_POSTGRES_PASSWORD
......
#!/usr/bin/env python #!/usr/bin/env python3
"""CLI service router""" """CLI service router"""
......
...@@ -115,6 +115,8 @@ def build_metadata(): ...@@ -115,6 +115,8 @@ def build_metadata():
sa.Column('abs_rshares', sa.Numeric, nullable=False, server_default='0'), sa.Column('abs_rshares', sa.Numeric, nullable=False, server_default='0'),
sa.Column('vote_rshares', sa.Numeric, nullable=False, server_default='0'), sa.Column('vote_rshares', sa.Numeric, nullable=False, server_default='0'),
sa.Column('total_vote_weight', sa.Numeric, nullable=False, server_default='0'), sa.Column('total_vote_weight', sa.Numeric, nullable=False, server_default='0'),
sa.Column('total_votes', sa.BigInteger, nullable=False, server_default='0'),
sa.Column('net_votes', sa.BigInteger, nullable=False, server_default='0'),
sa.Column('active', sa.DateTime, nullable=False, server_default='1970-01-01 00:00:00'), sa.Column('active', sa.DateTime, nullable=False, server_default='1970-01-01 00:00:00'),
sa.Column('cashout_time', sa.DateTime, nullable=False, server_default='1970-01-01 00:00:00'), sa.Column('cashout_time', sa.DateTime, nullable=False, server_default='1970-01-01 00:00:00'),
sa.Column('percent_hbd', sa.Integer, nullable=False, server_default='10000'), sa.Column('percent_hbd', sa.Integer, nullable=False, server_default='10000'),
...@@ -203,7 +205,7 @@ def build_metadata(): ...@@ -203,7 +205,7 @@ def build_metadata():
sa.Index('hive_votes_voter_id_post_id_idx', 'voter_id', 'post_id'), # probably this index is redundant to hive_votes_voter_id_last_update_idx because of starting voter_id. sa.Index('hive_votes_voter_id_post_id_idx', 'voter_id', 'post_id'), # probably this index is redundant to hive_votes_voter_id_last_update_idx because of starting voter_id.
sa.Index('hive_votes_voter_id_last_update_idx', 'voter_id', 'last_update'), # this index is critical for hive_accounts_info_view performance sa.Index('hive_votes_voter_id_last_update_idx', 'voter_id', 'last_update'), # this index is critical for hive_accounts_info_view performance
sa.Index('hive_votes_post_id_voter_id_idx', 'post_id', 'voter_id'), sa.Index('hive_votes_post_id_voter_id_idx', 'post_id', 'voter_id'),
sa.Index('hive_votes_block_num_idx', 'block_num') # this is also important for hive_accounts_info_view sa.Index('hive_votes_block_num_idx', 'block_num') # this is also important for hive_accounts_info_view
) )
sa.Table( sa.Table(
...@@ -561,6 +563,7 @@ def setup(db): ...@@ -561,6 +563,7 @@ def setup(db):
"hive_posts_base_view.sql", "hive_posts_base_view.sql",
"hive_posts_view.sql", "hive_posts_view.sql",
"hive_votes_view.sql", "hive_votes_view.sql",
"hive_muted_accounts_view.sql",
"hive_post_operations.sql", "hive_post_operations.sql",
"head_block_time.sql", "head_block_time.sql",
"update_feed_cache.sql", "update_feed_cache.sql",
......
...@@ -58,7 +58,8 @@ BEGIN ...@@ -58,7 +58,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
JOIN JOIN
( (
......
...@@ -46,7 +46,8 @@ BEGIN ...@@ -46,7 +46,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT hp1.id SELECT hp1.id
......
...@@ -50,7 +50,8 @@ BEGIN ...@@ -50,7 +50,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
WHERE WHERE
......
...@@ -46,7 +46,8 @@ BEGIN ...@@ -46,7 +46,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
WHERE WHERE
......
...@@ -46,7 +46,8 @@ BEGIN ...@@ -46,7 +46,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
......
...@@ -44,7 +44,8 @@ BEGIN ...@@ -44,7 +44,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
WHERE WHERE
......
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created;
CREATE FUNCTION bridge_get_ranked_post_by_created( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_created( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -43,7 +43,8 @@ BEGIN ...@@ -43,7 +43,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -55,6 +56,7 @@ BEGIN ...@@ -55,6 +56,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as created ) as created
JOIN hive_posts_view hp ON hp.id = created.id JOIN hive_posts_view hp ON hp.id = created.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY created.id DESC ORDER BY created.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -62,7 +64,7 @@ $function$ ...@@ -62,7 +64,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot;
CREATE FUNCTION bridge_get_ranked_post_by_hot( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_hot( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -110,7 +112,8 @@ BEGIN ...@@ -110,7 +112,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -124,6 +127,7 @@ BEGIN ...@@ -124,6 +127,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as hot ) as hot
JOIN hive_posts_view hp ON hp.id = hot.id JOIN hive_posts_view hp ON hp.id = hot.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY hot.hot DESC, hot.id DESC ORDER BY hot.hot DESC, hot.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -131,7 +135,7 @@ $function$ ...@@ -131,7 +135,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted;
CREATE FUNCTION bridge_get_ranked_post_by_muted( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_muted( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -179,7 +183,8 @@ BEGIN ...@@ -179,7 +183,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -194,6 +199,7 @@ BEGIN ...@@ -194,6 +199,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -201,7 +207,7 @@ $function$ ...@@ -201,7 +207,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments;
CREATE FUNCTION bridge_get_ranked_post_by_payout_comments( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_payout_comments( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -249,7 +255,8 @@ BEGIN ...@@ -249,7 +255,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -263,6 +270,7 @@ BEGIN ...@@ -263,6 +270,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -270,7 +278,7 @@ $function$ ...@@ -270,7 +278,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout;
CREATE FUNCTION bridge_get_ranked_post_by_payout( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN ) CREATE FUNCTION bridge_get_ranked_post_by_payout( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -320,7 +328,8 @@ BEGIN ...@@ -320,7 +328,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -335,6 +344,7 @@ BEGIN ...@@ -335,6 +344,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -342,7 +352,7 @@ $function$ ...@@ -342,7 +352,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted;
CREATE FUNCTION bridge_get_ranked_post_by_promoted( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_promoted( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -390,7 +400,8 @@ BEGIN ...@@ -390,7 +400,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -404,6 +415,7 @@ BEGIN ...@@ -404,6 +415,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as promoted ) as promoted
JOIN hive_posts_view hp ON hp.id = promoted.id JOIN hive_posts_view hp ON hp.id = promoted.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY promoted.promoted DESC, promoted.id DESC ORDER BY promoted.promoted DESC, promoted.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -411,7 +423,7 @@ $function$ ...@@ -411,7 +423,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends;
CREATE FUNCTION bridge_get_ranked_post_by_trends( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_trends( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -459,7 +471,8 @@ BEGIN ...@@ -459,7 +471,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -473,6 +486,7 @@ BEGIN ...@@ -473,6 +486,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as trends ) as trends
JOIN hive_posts_view hp ON hp.id = trends.id JOIN hive_posts_view hp ON hp.id = trends.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY trends.trend DESC, trends.id DESC ORDER BY trends.trend DESC, trends.id DESC
LIMIT _limit; LIMIT _limit;
END END
......
DROP FUNCTION IF EXISTS bridge_get_ranked_post_pinned_for_community; 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 ) CREATE FUNCTION bridge_get_ranked_post_pinned_for_community( in _community VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -39,18 +39,20 @@ $function$ ...@@ -39,18 +39,20 @@ $function$
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_communities hc ON hc.id = hp.community_id JOIN hive_communities hc ON hc.id = hp.community_id
WHERE hc.name = _community AND hp.is_pinned WHERE hc.name = _community AND hp.is_pinned
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY hp.id DESC ORDER BY hp.id DESC
LIMIT _limit; LIMIT _limit;
$function$ $function$
language sql STABLE; language sql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_trends_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN ) CREATE FUNCTION bridge_get_ranked_post_by_trends_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -98,7 +100,8 @@ BEGIN ...@@ -98,7 +100,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -114,6 +117,7 @@ BEGIN ...@@ -114,6 +117,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as trends ) as trends
JOIN hive_posts_view hp ON hp.id = trends.id JOIN hive_posts_view hp ON hp.id = trends.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY trends.trend DESC, trends.id DESC ORDER BY trends.trend DESC, trends.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -121,7 +125,7 @@ $function$ ...@@ -121,7 +125,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_promoted_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_promoted_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -169,7 +173,8 @@ BEGIN ...@@ -169,7 +173,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -184,6 +189,7 @@ BEGIN ...@@ -184,6 +189,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as promoted ) as promoted
JOIN hive_posts_view hp ON hp.id = promoted.id JOIN hive_posts_view hp ON hp.id = promoted.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY promoted.promoted DESC, promoted.id DESC ORDER BY promoted.promoted DESC, promoted.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -191,7 +197,7 @@ $function$ ...@@ -191,7 +197,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_payout_for_community(in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_payout_for_community(in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -241,7 +247,8 @@ BEGIN ...@@ -241,7 +247,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -256,6 +263,7 @@ BEGIN ...@@ -256,6 +263,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -263,7 +271,7 @@ $function$ ...@@ -263,7 +271,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_payout_comments_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_payout_comments_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -311,7 +319,8 @@ BEGIN ...@@ -311,7 +319,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -326,6 +335,7 @@ BEGIN ...@@ -326,6 +335,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -333,7 +343,7 @@ $function$ ...@@ -333,7 +343,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_muted_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_muted_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -381,7 +391,8 @@ BEGIN ...@@ -381,7 +391,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -397,6 +408,7 @@ BEGIN ...@@ -397,6 +408,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -404,7 +416,7 @@ $function$ ...@@ -404,7 +416,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_hot_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_hot_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -452,7 +464,8 @@ BEGIN ...@@ -452,7 +464,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -467,6 +480,7 @@ BEGIN ...@@ -467,6 +480,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as hot ) as hot
JOIN hive_posts_view hp ON hp.id = hot.id JOIN hive_posts_view hp ON hp.id = hot.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY hot.hot DESC, hot.id DESC ORDER BY hot.hot DESC, hot.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -474,7 +488,7 @@ $function$ ...@@ -474,7 +488,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created_for_community; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created_for_community;
CREATE FUNCTION bridge_get_ranked_post_by_created_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN ) CREATE FUNCTION bridge_get_ranked_post_by_created_for_community( in _community VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -518,7 +532,8 @@ BEGIN ...@@ -518,7 +532,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -534,6 +549,7 @@ BEGIN ...@@ -534,6 +549,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as created ) as created
JOIN hive_posts_view hp ON hp.id = created.id JOIN hive_posts_view hp ON hp.id = created.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY created.id DESC ORDER BY created.id DESC
LIMIT _limit; LIMIT _limit;
END END
......
...@@ -45,12 +45,14 @@ BEGIN ...@@ -45,12 +45,14 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_subscriptions hs ON hp.community_id = hs.community_id JOIN hive_subscriptions hs ON hp.community_id = hs.community_id
JOIN hive_accounts_view ha ON ha.id = hp.author_id JOIN hive_accounts_view ha ON ha.id = hp.author_id
WHERE hs.account_id = __account_id AND hp.depth = 0 AND NOT ha.is_grayed AND ( __post_id = 0 OR hp.id < __post_id ) WHERE hs.account_id = __account_id AND hp.depth = 0 AND NOT ha.is_grayed AND ( __post_id = 0 OR hp.id < __post_id )
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY hp.id DESC ORDER BY hp.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -72,7 +74,7 @@ BEGIN ...@@ -72,7 +74,7 @@ BEGIN
SELECT hp.sc_hot INTO __hot_limit FROM hive_posts hp WHERE hp.id = __post_id; SELECT hp.sc_hot INTO __hot_limit FROM hive_posts hp WHERE hp.id = __post_id;
END IF; END IF;
__account_id = find_account_id( _observer, True ); __account_id = find_account_id( _observer, True );
RETURN QUERY SELECT RETURN QUERY SELECT
hp.id, hp.id,
hp.author, hp.author,
hp.parent_author, hp.parent_author,
...@@ -108,12 +110,14 @@ BEGIN ...@@ -108,12 +110,14 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_subscriptions hs ON hp.community_id = hs.community_id JOIN hive_subscriptions hs ON hp.community_id = hs.community_id
WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.depth = 0 WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.depth = 0
AND ( __post_id = 0 OR hp.sc_hot < __hot_limit OR ( hp.sc_hot = __hot_limit AND hp.id < __post_id ) ) AND ( __post_id = 0 OR hp.sc_hot < __hot_limit OR ( hp.sc_hot = __hot_limit AND hp.id < __post_id ) )
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY hp.sc_hot DESC, hp.id DESC ORDER BY hp.sc_hot DESC, hp.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -171,7 +175,8 @@ BEGIN ...@@ -171,7 +175,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -186,6 +191,7 @@ BEGIN ...@@ -186,6 +191,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -245,12 +251,14 @@ BEGIN ...@@ -245,12 +251,14 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_subscriptions hs ON hp.community_id = hs.community_id JOIN hive_subscriptions hs ON hp.community_id = hs.community_id
WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.payout_at BETWEEN __head_block_time + interval '12 hours' AND __head_block_time + interval '36 hours' WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.payout_at BETWEEN __head_block_time + interval '12 hours' AND __head_block_time + interval '36 hours'
AND ( __post_id = 0 OR ( hp.payout + hp.pending_payout ) < __payout_limit OR ( ( hp.payout + hp.pending_payout ) = __payout_limit AND hp.id < __post_id ) ) AND ( __post_id = 0 OR ( hp.payout + hp.pending_payout ) < __payout_limit OR ( ( hp.payout + hp.pending_payout ) = __payout_limit AND hp.id < __post_id ) )
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY ( hp.payout + hp.pending_payout ) DESC, hp.id DESC ORDER BY ( hp.payout + hp.pending_payout ) DESC, hp.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -308,12 +316,14 @@ BEGIN ...@@ -308,12 +316,14 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_subscriptions hs ON hp.community_id = hs.community_id JOIN hive_subscriptions hs ON hp.community_id = hs.community_id
WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.promoted > 0 WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND hp.promoted > 0
AND ( __post_id = 0 OR hp.promoted < __promoted_limit OR ( hp.promoted = __promoted_limit AND hp.id < __post_id ) ) AND ( __post_id = 0 OR hp.promoted < __promoted_limit OR ( hp.promoted = __promoted_limit AND hp.id < __post_id ) )
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY hp.promoted DESC, hp.id DESC ORDER BY hp.promoted DESC, hp.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -331,6 +341,7 @@ DECLARE ...@@ -331,6 +341,7 @@ DECLARE
__trending_limit FLOAT := 0; __trending_limit FLOAT := 0;
BEGIN BEGIN
__post_id = find_comment_id( _author, _permlink, True ); __post_id = find_comment_id( _author, _permlink, True );
__account_id = find_account_id( _observer, True );
IF __post_id <> 0 THEN IF __post_id <> 0 THEN
SELECT hp.sc_trend INTO __trending_limit FROM hive_posts hp WHERE hp.id = __post_id; SELECT hp.sc_trend INTO __trending_limit FROM hive_posts hp WHERE hp.id = __post_id;
END IF; END IF;
...@@ -371,7 +382,8 @@ BEGIN ...@@ -371,7 +382,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -387,6 +399,7 @@ BEGIN ...@@ -387,6 +399,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) trending ) trending
JOIN hive_posts_view hp ON trending.id = hp.id JOIN hive_posts_view hp ON trending.id = hp.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY trending.sc_trend DESC, trending.id DESC ORDER BY trending.sc_trend DESC, trending.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -444,13 +457,15 @@ BEGIN ...@@ -444,13 +457,15 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
hive_posts_view hp hive_posts_view hp
JOIN hive_subscriptions hs ON hp.community_id = hs.community_id JOIN hive_subscriptions hs ON hp.community_id = hs.community_id
JOIN hive_accounts_view ha ON ha.id = hp.author_id JOIN hive_accounts_view ha ON ha.id = hp.author_id
WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND ha.is_grayed AND ( hp.payout + hp.pending_payout ) > 0 WHERE hs.account_id = __account_id AND NOT hp.is_paidout AND ha.is_grayed AND ( hp.payout + hp.pending_payout ) > 0
AND ( __post_id = 0 OR ( hp.payout + hp.pending_payout ) < __payout_limit OR ( ( hp.payout + hp.pending_payout ) = __payout_limit AND hp.id < __post_id ) ) AND ( __post_id = 0 OR ( hp.payout + hp.pending_payout ) < __payout_limit OR ( ( hp.payout + hp.pending_payout ) = __payout_limit AND hp.id < __post_id ) )
AND (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE True END)
ORDER BY ( hp.payout + hp.pending_payout ) DESC, hp.id DESC ORDER BY ( hp.payout + hp.pending_payout ) DESC, hp.id DESC
LIMIT _limit; LIMIT _limit;
END END
......
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created_for_tag; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_created_for_tag;
CREATE FUNCTION bridge_get_ranked_post_by_created_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_created_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -45,7 +45,8 @@ BEGIN ...@@ -45,7 +45,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -60,6 +61,7 @@ BEGIN ...@@ -60,6 +61,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as created ) as created
JOIN hive_posts_view hp ON hp.id = created.id JOIN hive_posts_view hp ON hp.id = created.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY created.id DESC ORDER BY created.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -67,7 +69,7 @@ $function$ ...@@ -67,7 +69,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot_for_tag; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_hot_for_tag;
CREATE FUNCTION bridge_get_ranked_post_by_hot_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_hot_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -117,7 +119,8 @@ BEGIN ...@@ -117,7 +119,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -132,6 +135,7 @@ BEGIN ...@@ -132,6 +135,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as hot ) as hot
JOIN hive_posts_view hp ON hp.id = hot.id JOIN hive_posts_view hp ON hp.id = hot.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY hot.hot DESC, hot.id DESC ORDER BY hot.hot DESC, hot.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -139,7 +143,7 @@ $function$ ...@@ -139,7 +143,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted_for_tag; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_muted_for_tag;
CREATE FUNCTION bridge_get_ranked_post_by_muted_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_muted_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -189,7 +193,8 @@ BEGIN ...@@ -189,7 +193,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -205,6 +210,7 @@ BEGIN ...@@ -205,6 +210,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -212,7 +218,7 @@ $function$ ...@@ -212,7 +218,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments_for_category; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_comments_for_category;
CREATE FUNCTION bridge_get_ranked_post_by_payout_comments_for_category( in _category VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_payout_comments_for_category( in _category VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -262,7 +268,8 @@ BEGIN ...@@ -262,7 +268,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -276,6 +283,7 @@ BEGIN ...@@ -276,6 +283,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -283,7 +291,7 @@ $function$ ...@@ -283,7 +291,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_for_category; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_payout_for_category;
CREATE FUNCTION bridge_get_ranked_post_by_payout_for_category( in _category VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN ) CREATE FUNCTION bridge_get_ranked_post_by_payout_for_category( in _category VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _bridge_api BOOLEAN, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -335,7 +343,8 @@ BEGIN ...@@ -335,7 +343,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -350,6 +359,7 @@ BEGIN ...@@ -350,6 +359,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as payout ) as payout
JOIN hive_posts_view hp ON hp.id = payout.id JOIN hive_posts_view hp ON hp.id = payout.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY payout.all_payout DESC, payout.id DESC ORDER BY payout.all_payout DESC, payout.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -357,7 +367,7 @@ $function$ ...@@ -357,7 +367,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted_for_tag; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_promoted_for_tag;
CREATE FUNCTION bridge_get_ranked_post_by_promoted_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_promoted_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -407,7 +417,8 @@ BEGIN ...@@ -407,7 +417,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -422,6 +433,7 @@ BEGIN ...@@ -422,6 +433,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as promoted ) as promoted
JOIN hive_posts_view hp ON hp.id = promoted.id JOIN hive_posts_view hp ON hp.id = promoted.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY promoted.promoted DESC, promoted.id DESC ORDER BY promoted.promoted DESC, promoted.id DESC
LIMIT _limit; LIMIT _limit;
END END
...@@ -429,7 +441,7 @@ $function$ ...@@ -429,7 +441,7 @@ $function$
language plpgsql STABLE; language plpgsql STABLE;
DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends_for_tag; DROP FUNCTION IF EXISTS bridge_get_ranked_post_by_trends_for_tag;
CREATE FUNCTION bridge_get_ranked_post_by_trends_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT ) CREATE FUNCTION bridge_get_ranked_post_by_trends_for_tag( in _tag VARCHAR, in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF bridge_api_post RETURNS SETOF bridge_api_post
AS AS
$function$ $function$
...@@ -479,7 +491,8 @@ BEGIN ...@@ -479,7 +491,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM FROM
( (
SELECT SELECT
...@@ -494,6 +507,7 @@ BEGIN ...@@ -494,6 +507,7 @@ BEGIN
LIMIT _limit LIMIT _limit
) as trends ) as trends
JOIN hive_posts_view hp ON hp.id = trends.id JOIN hive_posts_view hp ON hp.id = trends.id
WHERE (CASE WHEN _observer IS NOT NULL THEN NOT EXISTS (SELECT 1 FROM muted_accounts_view WHERE observer = _observer AND muted = hp.author) ELSE true END)
ORDER BY trends.trend DESC, trends.id DESC ORDER BY trends.trend DESC, trends.id DESC
LIMIT _limit; LIMIT _limit;
END END
......
...@@ -35,7 +35,8 @@ CREATE TYPE bridge_api_post AS ( ...@@ -35,7 +35,8 @@ CREATE TYPE bridge_api_post AS (
community_title VARCHAR, community_title VARCHAR,
role_id SMALLINT, role_id SMALLINT,
is_pinned BOOLEAN, is_pinned BOOLEAN,
curator_payout_value VARCHAR curator_payout_value VARCHAR,
is_muted BOOLEAN
); );
DROP TYPE IF EXISTS bridge_api_post_reblogs CASCADE; DROP TYPE IF EXISTS bridge_api_post_reblogs CASCADE;
......
...@@ -52,7 +52,8 @@ BEGIN ...@@ -52,7 +52,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
WHERE ( hp.author = _author ) AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) ) AND hp.depth > 0 WHERE ( hp.author = _author ) AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) ) AND hp.depth > 0
ORDER BY hp.id DESC ORDER BY hp.id DESC
......
...@@ -62,7 +62,8 @@ BEGIN ...@@ -62,7 +62,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
JOIN hive_feed_cache hfc ON hp.id = hfc.post_id JOIN hive_feed_cache hfc ON hp.id = hfc.post_id
WHERE hfc.account_id = __account_id AND ( ( __post_id = 0 ) OR ( hfc.created_at <= __created_at ) ) WHERE hfc.account_id = __account_id AND ( ( __post_id = 0 ) OR ( hfc.created_at <= __created_at ) )
......
...@@ -52,7 +52,8 @@ BEGIN ...@@ -52,7 +52,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
WHERE ( hp.author = _author ) AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) ) AND hp.depth = 0 WHERE ( hp.author = _author ) AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) ) AND hp.depth = 0
ORDER BY hp.id DESC ORDER BY hp.id DESC
......
...@@ -62,7 +62,8 @@ BEGIN ...@@ -62,7 +62,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
JOIN JOIN
( (
......
...@@ -52,7 +52,8 @@ BEGIN ...@@ -52,7 +52,8 @@ BEGIN
hp.community_title, hp.community_title,
hp.role_id, hp.role_id,
hp.is_pinned, hp.is_pinned,
hp.curator_payout_value hp.curator_payout_value,
hp.is_muted
FROM hive_posts_view hp FROM hive_posts_view hp
WHERE WHERE
hp.author = _author AND hp.depth > 0 AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) ) hp.author = _author AND hp.depth > 0 AND ( ( __post_id = 0 ) OR ( hp.id <= __post_id ) )
......
...@@ -14,6 +14,7 @@ for sql in postgres_handle_view_changes.sql \ ...@@ -14,6 +14,7 @@ for sql in postgres_handle_view_changes.sql \
hive_posts_base_view.sql \ hive_posts_base_view.sql \
hive_posts_view.sql \ hive_posts_view.sql \
hive_votes_view.sql \ hive_votes_view.sql \
hive_muted_accounts_view.sql \
hive_post_operations.sql \ hive_post_operations.sql \
head_block_time.sql \ head_block_time.sql \
update_feed_cache.sql \ update_feed_cache.sql \
......