Skip to content

Commit

Permalink
Removed hive_payments table and promoted feature
Browse files Browse the repository at this point in the history
  • Loading branch information
drov0 authored and dnotestein committed Jan 23, 2025
1 parent 088757c commit aad75bc
Show file tree
Hide file tree
Showing 1,027 changed files with 215 additions and 555,084 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,6 @@ condenser_api.get_trending_tags
condenser_api.get_discussions_by_trending
condenser_api.get_discussions_by_hot
condenser_api.get_discussions_by_promoted
condenser_api.get_discussions_by_created
condenser_api.get_discussions_by_blog
Expand Down
1 change: 0 additions & 1 deletion hive/db/db_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def disableable_indexes(cls):
'hive_posts_community_id_not_is_pinned_idx',
'hive_posts_community_id_not_is_paidout_idx',
'hive_posts_payout_at_idx',
'hive_posts_promoted_id_idx',
'hive_posts_sc_trend_id_idx',
'hive_posts_sc_hot_id_idx',
'hive_posts_block_num_idx',
Expand Down
27 changes: 0 additions & 27 deletions hive/db/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def build_metadata():
sa.Column('is_muted', BOOLEAN, nullable=False, server_default='0'),
sa.Column('muted_reasons', sa.Integer, nullable=False, server_default='0'),
sa.Column('is_valid', BOOLEAN, nullable=False, server_default='1'),
sa.Column('promoted', sa.types.DECIMAL(10, 3), nullable=False, server_default='0'),
sa.Column('children', sa.Integer, nullable=False, server_default='0'),
# core stats/indexes
sa.Column('payout', sa.types.DECIMAL(10, 3), nullable=False, server_default='0'),
Expand Down Expand Up @@ -133,12 +132,6 @@ def build_metadata():
postgresql_where=sql_text("NOT is_paidout AND depth = 0 AND counter_deleted = 0")),

sa.Index('hive_posts_payout_at_idx', 'payout_at'),
sa.Index(
'hive_posts_promoted_id_idx',
'promoted',
'id',
postgresql_where=sql_text("NOT is_paidout AND counter_deleted = 0"),
),
sa.Index(
'hive_posts_sc_trend_id_idx',
'sc_trend',
Expand Down Expand Up @@ -296,25 +289,6 @@ def build_metadata():
sa.Index('hive_reblogs_block_num_idx', 'block_num'),
)

sa.Table(
'hive_payments',
metadata,
sa.Column('hive_rowid', sa.BigInteger, server_default=hive_rowid_seq.next_value(), nullable=False),
sa.Column('id', sa.Integer, primary_key=True),
sa.Column('block_num', sa.Integer, nullable=False),
sa.Column('tx_idx', SMALLINT, nullable=False),
sa.Column('post_id', sa.Integer, nullable=False),
sa.Column('from_account', sa.Integer, nullable=False),
sa.Column('to_account', sa.Integer, nullable=False),
sa.Column('amount', sa.types.DECIMAL(10, 3), nullable=False),
sa.Column('token', VARCHAR(5), nullable=False),
sa.ForeignKeyConstraint(['from_account'], ['hive_accounts.id'], name='hive_payments_fk1', deferrable=True, postgresql_not_valid=True),
sa.ForeignKeyConstraint(['to_account'], ['hive_accounts.id'], name='hive_payments_fk2', deferrable=True, postgresql_not_valid=True),
sa.ForeignKeyConstraint(['post_id'], ['hive_posts.id'], name='hive_payments_fk3', deferrable=True, postgresql_not_valid=True),
sa.Index('hive_payments_from', 'from_account'),
sa.Index('hive_payments_to', 'to_account'),
)

sa.Table(
'hive_feed_cache',
metadata,
Expand Down Expand Up @@ -826,7 +800,6 @@ def reset_autovac(db):
'hive_follows': (5000, 5000),
'hive_feed_cache': (5000, 5000),
'hive_reblogs': (5000, 5000),
'hive_payments': (5000, 5000),
}

for table, (n_vacuum, n_analyze) in autovac_config.items():
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_account_posts_by_blog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_account_posts_by_payout.sql
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_account_posts_by_posts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_by_feed_with_reblog.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_discussion.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
1 change: 0 additions & 1 deletion hive/db/sql_scripts/bridge_get_post.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
83 changes: 0 additions & 83 deletions hive/db/sql_scripts/bridge_get_ranked_post_for_all.sql
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down Expand Up @@ -114,7 +113,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down Expand Up @@ -192,7 +190,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down Expand Up @@ -269,7 +266,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down Expand Up @@ -348,7 +344,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down Expand Up @@ -380,83 +375,6 @@ END
$function$
language plpgsql STABLE;

DROP FUNCTION IF EXISTS hivemind_app.bridge_get_ranked_post_by_promoted;
CREATE FUNCTION hivemind_app.bridge_get_ranked_post_by_promoted( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF hivemind_app.bridge_api_post
AS
$function$
DECLARE
__post_id INT;
__promoted_limit hivemind_app.hive_posts.promoted%TYPE;
__observer_id INT;
BEGIN
__post_id = hivemind_app.find_comment_id( _author, _permlink, True );
__observer_id = hivemind_app.find_account_id( _observer, True );
IF __post_id <> 0 THEN
SELECT hp.promoted INTO __promoted_limit FROM hivemind_app.hive_posts hp WHERE hp.id = __post_id;
END IF;
RETURN QUERY
WITH promoted AS MATERIALIZED -- bridge_get_ranked_post_by_promoted
(
SELECT
hp1.id,
hp1.promoted
FROM hivemind_app.live_posts_comments_view hp1
WHERE NOT hp1.is_paidout
AND hp1.promoted > 0
AND ( __post_id = 0 OR hp1.promoted < __promoted_limit OR ( hp1.promoted = __promoted_limit AND hp1.id < __post_id ) )
AND (NOT EXISTS (SELECT 1 FROM hivemind_app.muted_accounts_by_id_view WHERE observer_id = __observer_id AND muted_id = hp1.author_id))
ORDER BY hp1.promoted DESC, hp1.id DESC
LIMIT _limit
)
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,
hp.is_muted,
hp.source,
hp.muted_reasons
FROM promoted,
LATERAL hivemind_app.get_full_post_view_by_id(promoted.id, __observer_id) hp
ORDER BY promoted.promoted DESC, promoted.id DESC
LIMIT _limit;
END
$function$
language plpgsql STABLE;

DROP FUNCTION IF EXISTS hivemind_app.bridge_get_ranked_post_by_trends;
CREATE FUNCTION hivemind_app.bridge_get_ranked_post_by_trends( in _author VARCHAR, in _permlink VARCHAR, in _limit SMALLINT, in _observer VARCHAR )
RETURNS SETOF hivemind_app.bridge_api_post
Expand Down Expand Up @@ -502,7 +420,6 @@ BEGIN
hp.body,
hp.category,
hp.depth,
hp.promoted,
hp.payout,
hp.pending_payout,
hp.payout_at,
Expand Down
Loading

0 comments on commit aad75bc

Please sign in to comment.