diff --git a/hive/db/schema.py b/hive/db/schema.py index 55b3bc09f3d6c337d3214d3bb37c5d68527d013b..7dc9ff1a187e0ae6b5f33f0912b4b3f63ed66d04 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -122,7 +122,7 @@ def build_metadata(): sa.Column('last_payout', 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('max_cashout_time', sa.DateTime, nullable=False, server_default='1970-01-01 00:00:00'), - sa.Column('percent_hbd', sa.Integer, nullable=False, server_default='0'), + sa.Column('percent_hbd', sa.Integer, nullable=False, server_default='10000'), sa.Column('reward_weight', sa.Integer, nullable=False, server_default='0'), sa.Column('parent_author_id', sa.Integer, nullable=False), @@ -130,8 +130,7 @@ def build_metadata(): sa.Column('curator_payout_value', sa.String(30), nullable=False, server_default=''), sa.Column('root_author_id', sa.Integer, nullable=False), sa.Column('root_permlink_id', sa.BigInteger, nullable=False), - sa.Column('max_accepted_payout', sa.String(30), nullable=False, server_default=''), - sa.Column('percent_steem_dollars', sa.Integer, nullable=False, server_default='-1'), + sa.Column('max_accepted_payout', sa.String(30), nullable=False, server_default='1000000.000 HBD'), sa.Column('allow_replies', BOOLEAN, nullable=False, server_default='1'), sa.Column('allow_votes', BOOLEAN, nullable=False, server_default='1'), sa.Column('allow_curation_rewards', BOOLEAN, nullable=False, server_default='1'), diff --git a/hive/indexer/blocks.py b/hive/indexer/blocks.py index 2d411726c82372d7bc336b642ad1bc845b8bb50b..223e27f79b33ecb36799b88439a6721053b42d6a 100644 --- a/hive/indexer/blocks.py +++ b/hive/indexer/blocks.py @@ -193,6 +193,8 @@ class Blocks: Accounts.dirty(op['author']) # lite - stats elif op_type == 'delete_comment_operation': Posts.delete_op(op) + elif op_type == 'comment_options_operation': + Posts.comment_options_op(op) elif op_type == 'vote_operation': if not is_initial_sync: Accounts.dirty(op['author']) # lite - rep diff --git a/hive/indexer/cached_post.py b/hive/indexer/cached_post.py index 111a65228fe4ffbc767d55c766e40b9ebbc5e1a8..505f1efdf705b32edb10bfd73413d4f036a3c07d 100644 --- a/hive/indexer/cached_post.py +++ b/hive/indexer/cached_post.py @@ -527,7 +527,7 @@ class CachedPost: ('root_author', legacy_data['root_author']), ('root_permlink', legacy_data['root_permlink']), ('max_accepted_payout', legacy_data['max_accepted_payout']), - ('percent_steem_dollars', legacy_data['percent_steem_dollars']), + ('percent_hbd', legacy_data['percent_hbd']), ('allow_replies', legacy_data['allow_replies']), ('allow_votes', legacy_data['allow_votes']), ('allow_curation_rewards', legacy_data['allow_curation_rewards']), diff --git a/hive/indexer/posts.py b/hive/indexer/posts.py index 403b3ddaa1e0e4d8ff016f55176b5c8f0911cf5f..a271e6b030d17d5bb60d970c2fdc56b02d5e133c 100644 --- a/hive/indexer/posts.py +++ b/hive/indexer/posts.py @@ -250,6 +250,34 @@ class Posts: DB.query(sql, child_id=child_id) + @classmethod + def comment_options_op(cls, op): + """ Process comment_options_operation """ + max_accepted_payout = legacy_amount(op['max_accepted_payout']) if 'max_accepted_payout' in op else '1000000.000 HBD' + allow_votes = op['allow_votes'] if 'allow_votes' in op else True + allow_curation_rewards = op['allow_curation_rewards'] if 'allow_curation_rewards' in op else True + percent_hbd = op['percent_hbd'] if 'percent_hbd' in op else 10000 + extensions = op['extensions'] if 'extensions' in op else [] + beneficiaries = [] + for extension in extensions: + if 'beneficiaries' in extensions: + beneficiaries = extension['beneficiaries'] + sql = """ + UPDATE + hive_posts hp + SET + max_accepted_payout = :max_accepted_payout, + percent_hbd = :percent_hbd, + allow_votes = :allow_votes, + allow_curation_rewards = :allow_curation_rewards + beneficiaries = :beneficiaries + WHERE + hp.author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND + hp.permlink_id = (SELECT id FROM hive_permlink_data WHERE permlink = :permlink) + """ + DB.query(sql, author=op['author'], permlink=op['permlink'], max_accepted_payout=max_accepted_payout, + percent_hbd=percent_hbd, allow_votes=allow_votes, allow_curation_rewards=allow_curation_rewards, + beneficiaries=beneficiaries) @classmethod def delete(cls, op): diff --git a/hive/server/bridge_api/objects.py b/hive/server/bridge_api/objects.py index 5e8a8331246814ab400519fb8483526daf13257d..8a2639df479094755e31a9edd25862314e49be37 100644 --- a/hive/server/bridge_api/objects.py +++ b/hive/server/bridge_api/objects.py @@ -73,7 +73,7 @@ async def load_posts_keyed(db, ids, truncate_body=0): ha_ra.name as root_author, hpd_rp.permlink as root_permlink, max_accepted_payout, - percent_steem_dollars, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, @@ -279,7 +279,7 @@ def _condenser_post_object(row, truncate_body=0): post['root_title'] = row['root_title'] post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] - post['percent_steem_dollars'] = row['percent_steem_dollars'] + post['percent_hbd'] = row['percent_hbd'] if paid: curator_payout = sbd_amount(row['curator_payout_value']) diff --git a/hive/server/common/objects.py b/hive/server/common/objects.py index 92fa2d3e3b243300f639a76821c943f8c8c5fdf3..f7b3d013d9d09491559bfd7d5c18277ad91feb8e 100644 --- a/hive/server/common/objects.py +++ b/hive/server/common/objects.py @@ -65,7 +65,7 @@ def condenser_post_object(row, truncate_body=0): post['root_title'] = row['root_title'] post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] - post['percent_steem_dollars'] = row['percent_steem_dollars'] + post['percent_hbd'] = row['percent_hbd'] if paid: curator_payout = sbd_amount(row['curator_payout_value']) diff --git a/hive/server/condenser_api/cursor.py b/hive/server/condenser_api/cursor.py index 31bb27788fb48f5c2d15ebdbf0358efe742ebe18..f5cbaf87aae911741930ef1a26c6d336f614cfd5 100644 --- a/hive/server/condenser_api/cursor.py +++ b/hive/server/condenser_api/cursor.py @@ -212,7 +212,7 @@ async def pids_by_query(db, sort, start_author, start_permlink, limit, tag): ha_ra.name as root_author, hpd_rp.permlink as root_permlink, max_accepted_payout, - percent_steem_dollars, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, diff --git a/hive/server/condenser_api/methods.py b/hive/server/condenser_api/methods.py index d9f4ed8a3cdece5572c896c7c1febda160bfa5e5..d6a104a38cf3afc8402ac215dee91a1bdfa6520c 100644 --- a/hive/server/condenser_api/methods.py +++ b/hive/server/condenser_api/methods.py @@ -47,7 +47,7 @@ SQL_TEMPLATE = """ ha_ra.name as root_author, hpd_rp.permlink as root_permlink, max_accepted_payout, - percent_steem_dollars, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, diff --git a/hive/server/condenser_api/objects.py b/hive/server/condenser_api/objects.py index 6b0a16a1bf671073604aac4cd60654f756034aea..3858448dd1761dca93ef75f0e5b6cf30ad25dac6 100644 --- a/hive/server/condenser_api/objects.py +++ b/hive/server/condenser_api/objects.py @@ -70,7 +70,7 @@ async def load_posts_keyed(db, ids, truncate_body=0): ha_ra.name as root_author, hpd_rp.permlink as root_permlink, max_accepted_payout, - percent_steem_dollars, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, @@ -231,7 +231,7 @@ def _condenser_post_object(row, truncate_body=0): post['root_title'] = row['root_title'] post['beneficiaries'] = row['beneficiaries'] post['max_accepted_payout'] = row['max_accepted_payout'] - post['percent_steem_dollars'] = row['percent_steem_dollars'] + post['percent_hbd'] = row['percent_hbd'] if paid: curator_payout = sbd_amount(row['curator_payout_value']) diff --git a/hive/server/database_api/methods.py b/hive/server/database_api/methods.py index f228142389fb464ab66456259275041fd2878b9d..5b8cf22c1f35c5c1d0d11c20c3f51899573425ce 100644 --- a/hive/server/database_api/methods.py +++ b/hive/server/database_api/methods.py @@ -31,7 +31,7 @@ SQL_TEMPLATE = """ ha_ra.name as root_author, hpd_rp.permlink as root_permlink, max_accepted_payout, - percent_steem_dollars, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, diff --git a/hive/utils/post.py b/hive/utils/post.py index 06b45b4c588198b1cc42c82cff368732857bad18..9c3b8f1a176ef3aaa69e58354b4941c060c2b642 100644 --- a/hive/utils/post.py +++ b/hive/utils/post.py @@ -67,7 +67,7 @@ def post_to_internal(post, post_id, level='insert', promoted=None): ('root_author', legacy_data['root_author']), ('root_permlink', legacy_data['root_permlink']), ('max_accepted_payout', legacy_data['max_accepted_payout']), - ('percent_steem_dollars', legacy_data['percent_steem_dollars']), + ('percent_hbd', legacy_data['percent_hbd']), ('allow_replies', legacy_data['allow_replies']), ('allow_votes', legacy_data['allow_votes']), ('allow_curation_rewards', legacy_data['allow_curation_rewards']), @@ -163,7 +163,7 @@ def post_basic(post): is_payout_declined = True # payout entirely in SP - is_full_power = int(post['percent_steem_dollars']) == 0 + is_full_power = int(post['percent_hbd']) == 0 return { 'json_metadata': md, @@ -186,7 +186,7 @@ def post_legacy(post): """ _legacy = ['id', 'url', 'root_comment', 'root_author', 'root_permlink', 'root_title', 'parent_author', 'parent_permlink', - 'max_accepted_payout', 'percent_steem_dollars', + 'max_accepted_payout', 'percent_hbd', 'curator_payout_value', 'allow_replies', 'allow_votes', 'allow_curation_rewards', 'beneficiaries'] return {k: v for k, v in post.items() if k in _legacy} diff --git a/scripts/update_hivemind_db.sql b/scripts/update_hivemind_db.sql index 3260bb069f1307a2ecf6b9150f65c5c80fe7da59..20bad2b3261cf1afb16d25e33d3b6d2821b092e3 100644 --- a/scripts/update_hivemind_db.sql +++ b/scripts/update_hivemind_db.sql @@ -121,7 +121,6 @@ CREATE TABLE IF NOT EXISTS hive_posts_new ( last_payout DATE DEFAULT '1970-01-01T00:00:00', cashout_time DATE DEFAULT '1970-01-01T00:00:00', max_cashout_time DATE DEFAULT '1970-01-01T00:00:00', - percent_hbd INT DEFAULT '0', reward_weight INT DEFAULT '0', -- columns from raw_json @@ -130,8 +129,8 @@ CREATE TABLE IF NOT EXISTS hive_posts_new ( curator_payout_value VARCHAR(30) DEFAULT '', root_author_id INT DEFAULT '-1', root_permlink_id BIGINT DEFAULT '-1', - max_accepted_payout VARCHAR(30) DEFAULT '', - percent_steem_dollars INT DEFAULT '-1', + max_accepted_payout VARCHAR(30) DEFAULT '1000000.000 HBD', + percent_hbd INT DEFAULT '10000', allow_replies BOOLEAN DEFAULT '1', allow_votes BOOLEAN DEFAULT '1', allow_curation_rewards BOOLEAN DEFAULT '1', @@ -253,7 +252,7 @@ CREATE TABLE legacy_comment_data ( root_author VARCHAR(16), root_permlink VARCHAR(255), max_accepted_payout VARCHAR(30), - percent_steem_dollars INT, + percent_hbd INT, allow_replies BOOLEAN, allow_votes BOOLEAN, allow_curation_rewards BOOLEAN, @@ -271,7 +270,7 @@ CREATE TYPE legacy_comment_type AS ( root_author VARCHAR(16), root_permlink VARCHAR(255), max_accepted_payout VARCHAR(16), - percent_steem_dollars INT, + percent_hbd INT, allow_replies BOOLEAN, allow_votes BOOLEAN, allow_curation_rewards BOOLEAN, @@ -285,7 +284,7 @@ INSERT INTO legacy_comment_data (id, raw_json) SELECT post_id, raw_json FROM hiv update legacy_comment_data lcd set (parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, max_accepted_payout, - percent_steem_dollars, allow_replies, allow_votes, allow_curation_rewards, + percent_hbd, allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title) = (SELECT parent_author, parent_permlink, @@ -308,7 +307,7 @@ UPDATE hive_posts_new hpn SET root_author_id = (SELECT id FROM hive_accounts WHERE name = lcd.root_author), root_permlink_id = (SELECT id FROM hive_permlink_data WHERE permlink = lcd.root_permlink), max_accepted_payout = lcd.max_accepted_payout, - percent_steem_dollars = lcd.percent_steem_dollars, + percent_hbd = lcd.percent_hbd, allow_replies = lcd.allow_replies, allow_votes = lcd.allow_votes, allow_curation_rewards = lcd.allow_curation_rewards, @@ -316,7 +315,7 @@ UPDATE hive_posts_new hpn SET url = lcd.url, root_title = lcd.root_title FROM (SELECT id, parent_author, parent_permlink, curator_payout_value, root_author, root_permlink, - max_accepted_payout, percent_steem_dollars, allow_replies, allow_votes, allow_curation_rewards, + max_accepted_payout, percent_hbd, allow_replies, allow_votes, allow_curation_rewards, beneficiaries, url, root_title FROM legacy_comment_data) AS lcd WHERE lcd.id = hpn.id; diff --git a/tests/utils/test_utils_post.py b/tests/utils/test_utils_post.py index be5159db1abc33056a71eae0b0b8cbc0e09e714f..b4621f9b62c82fe05d1d46e9b42195b673d731ea 100644 --- a/tests/utils/test_utils_post.py +++ b/tests/utils/test_utils_post.py @@ -73,7 +73,7 @@ POST_1 = { "parent_author": "", "parent_permlink": "spam", "pending_payout_value": "0.000 HBD", - "percent_steem_dollars": 10000, + "percent_hbd": 10000, "permlink": "june-spam", "promoted": "0.000 HBD", "reblogged_by": [], @@ -121,7 +121,7 @@ POST_2 = { "parent_author": "", "parent_permlink": "spam", "pending_payout_value": "0.000 HBD", - "percent_steem_dollars": 10000, + "percent_hbd": 10000, "permlink": "june-spam", "promoted": "0.000 HBD", "reblogged_by": [], @@ -182,7 +182,7 @@ def test_post_legacy(): 'max_accepted_payout': '1000000.000 HBD', 'parent_author': '', 'parent_permlink': 'spam', - 'percent_steem_dollars': 10000, + 'percent_hbd': 10000, 'root_author': 'test-safari', 'root_permlink': 'june-spam', 'root_title': 'June Spam',