diff --git a/hive/db/schema.py b/hive/db/schema.py index 6a3e29a681b524145edd1b0f49ceebeb89473c27..82d20b073b7a1f76555ec5f22263573d7e06b42b 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -231,6 +231,8 @@ def build_metadata(): sa.Column('following', sa.Integer, nullable=False), sa.Column('state', SMALLINT, nullable=False, server_default='1'), sa.Column('created_at', sa.DateTime, nullable=False), + sa.Column('blacklisted', sa.Boolean, nullable=False, server_default='0'), + sa.Column('follow_blacklists', sa.Boolean, nullable=False, server_default='0'), sa.PrimaryKeyConstraint('following', 'follower', name='hive_follows_pk'), # core sa.Index('hive_follows_ix5a', 'following', 'state', 'created_at', 'follower'), diff --git a/hive/indexer/follow.py b/hive/indexer/follow.py index 84fb7cadc7bf62cdee080a7bdf9233cda5c91b29..33461156ae9791184abe4dbd91e3308452d857f3 100644 --- a/hive/indexer/follow.py +++ b/hive/indexer/follow.py @@ -64,13 +64,44 @@ class Follow: flr = op['flr'], flg = op['flg'], state = op['state'], - at = op['at']) + at = op['at'], + blk=False, + follow_blk=False) else: old_state = cls._get_follow_db_state(op['flr'], op['flg']) + if new_state == (old_state or 0): + return + sql = '' + # insert or update state - DB.query(FOLLOW_ITEM_INSERT_QUERY, **op) - # track count deltas + if old_state is None: + sql = """INSERT INTO hive_follows (follower, following, + created_at, state, blacklisted, follow_blacklists) VALUES (:flr, :flg, :at, :state, %s)""" + if new_state == 3: + sql = sql % """ true, false """ + elif new_state == 4: + sql = sql % """ false, true """ + else: + sql = sql % """false, false""" + else: + if new_state < 3: + sql = """UPDATE hive_follows SET state = :state + WHERE follower = :flr AND following = :flg""" + elif new_state == 3: + sql = """UPDATE hive_follows SET blacklisted = true + WHERE follower = :flr AND following = :flg""" + elif new_state == 4: + sql = """UPDATE hive_follows SET follow_blacklists = true + WHERE follower = :flr AND following = :flg""" + elif new_state == 5: + sql = """UPDATE hive_follows SET blacklisted = false + WHERE follower = :flr AND following = :flg""" + elif new_state == 6: + sql = """UPDATE hive_follows SET follow_blacklists = false + WHERE follower = :flr AND following = :flg""" + DB.query(sql, **op) + if new_state == 1: Follow.follow(op['flr'], op['flg']) if old_state is None: @@ -92,7 +123,7 @@ class Follow: what = first(op['what']) or '' if not isinstance(what, str): return None - defs = {'': 0, 'blog': 1, 'ignore': 2} + defs = {'': 0, 'blog': 1, 'ignore': 2, 'blacklist': 3, 'follow_blacklist': 4, 'unblacklist': 5, 'unfollow_blacklist': 6} if what not in defs: return None @@ -142,7 +173,7 @@ class Follow: @classmethod def _flush_follow_items(cls): sql_prefix = """ - INSERT INTO hive_follows as hf (follower, following, created_at, state) + INSERT INTO hive_follows as hf (follower, following, created_at, state, blacklisted, follow_blacklists) VALUES """ sql_postfix = """ @@ -158,14 +189,14 @@ class Follow: count = 0 for (k, follow_item) in cls.follow_items_to_flush.items(): if count < limit: - values.append("({}, {}, '{}', {})".format(follow_item['flr'], follow_item['flg'], follow_item['at'], follow_item['state'])) + values.append("({}, {}, '{}', {}, {}, {})".format(follow_item['flr'], follow_item['flg'], follow_item['at'], follow_item['state'], follow_item['blk'], follow_item['follow_blk'])) count = count + 1 else: query = sql_prefix + ",".join(values) query += sql_postfix DB.query(query) values.clear() - values.append("({}, {}, '{}', {})".format(follow_item['flr'], follow_item['flg'], follow_item['at'], follow_item['state'])) + values.append("({}, {}, '{}', {}, {}, {})".format(follow_item['flr'], follow_item['flg'], follow_item['at'], follow_item['state'], follow_item['blk'], follow_item['follow_blk'])) count = 1 if len(values): diff --git a/hive/server/bridge_api/methods.py b/hive/server/bridge_api/methods.py index 64dd8494912a5382579a786e3ab6796c89dc8037..cf6ce6515b0fca1b48b8c3b85164aa3b8e1a836f 100644 --- a/hive/server/bridge_api/methods.py +++ b/hive/server/bridge_api/methods.py @@ -18,7 +18,6 @@ ROLES = {-2: 'muted', 0: 'guest', 2: 'member', 4: 'mod', 6: 'admin', 8: 'owner'} SQL_TEMPLATE = """ SELECT hp.id, - community_id, ha_a.name as author, hpd_p.permlink as permlink, (SELECT title FROM hive_post_data WHERE hive_post_data.id = hp.id) as title, @@ -104,12 +103,16 @@ async def get_post(context, author, permlink, observer=None): valid_account(author) valid_permlink(permlink) + blacklists_for_user = None + if observer and context: + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) + sql = "---bridge_api.get_post\n" + SQL_TEMPLATE + """ WHERE ha_a.name = :author AND hpd_p.permlink = :permlink AND NOT hive_posts.is_deleted """ result = await db.query_all(sql, author=author, permlink=permlink) assert len(result) == 1, 'invalid author/permlink or post not found in cache' post = _condenser_post_object(result[0]) - post['blacklists'] = Mutes.lists(post['author'], result[0]['author_rep']) + post = await append_statistics_to_post(post, result[0], False, blacklists_for_user) return post @return_error_info @@ -158,18 +161,18 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='', if start_author and start_permlink: if sort == 'trending': sql = sql % """ AND hp.sc_trend <= (SELECT sc_trend FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) - AND hp.post_id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ + AND hp.id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ elif sort == 'hot': sql = sql % """ AND hp.sc_hot <= (SELECT sc_hot FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) - AND hp.post_id != (SELECT post_id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ + AND hp.id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ elif sort == 'created': - sql = sql % """ AND hp.post_id < (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ + sql = sql % """ AND hp.id < (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ elif sort == 'promoted': sql = sql % """ AND hp.promoted <= (SELECT promoted FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) - AND hp.post_id != (SELECT post_id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ + AND hp.id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ else: sql = sql % """ AND hp.payout <= (SELECT payout FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) - AND hp.post_id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ + AND hp.id != (SELECT id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink)) %s """ else: sql = sql % """ %s """ @@ -191,7 +194,7 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='', if sort in ['payout', 'payout_comments']: sql = sql % """ AND hp.category = :tag """ else: - sql = sql % """ AND hp.post_id IN + sql = sql % """ AND hp.post IN (SELECT post_id FROM @@ -207,11 +210,15 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='', posts = [] pinned_post_ids = [] + blacklists_for_user = None + if observer and context: + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) + if pinned_sql: pinned_result = await db.query_all(pinned_sql, author=start_author, limit=limit, tag=tag, permlink=start_permlink, community_name=tag, observer=observer) for row in pinned_result: post = _condenser_post_object(row) - post = append_statistics_to_post(post, row, True) + post = await append_statistics_to_post(post, row, True, blacklists_for_user) limit = limit - 1 posts.append(post) pinned_post_ids.append(post['post_id']) @@ -219,14 +226,28 @@ async def get_ranked_posts(context, sort, start_author='', start_permlink='', sql_result = await db.query_all(sql, author=start_author, limit=limit, tag=tag, permlink=start_permlink, community_name=tag, observer=observer) for row in sql_result: post = _condenser_post_object(row) - post = append_statistics_to_post(post, row, False) + post = await append_statistics_to_post(post, row, False, blacklists_for_user) if post['post_id'] in pinned_post_ids: continue posts.append(post) return posts -def append_statistics_to_post(post, row, is_pinned): - post['blacklists'] = Mutes.lists(row['author'], row['author_rep']) +async def append_statistics_to_post(post, row, is_pinned, blacklists_for_user=None): + """ apply information such as blacklists and community names/roles to a given post """ + if not blacklists_for_user: + post['blacklists'] = Mutes.lists(row['author'], row['author_rep']) + else: + post['blacklists'] = [] + if row['author'] in blacklists_for_user: + blacklists = blacklists_for_user[row['author']] + for blacklist in blacklists: + post['blacklists'].append(blacklist) + reputation = int(row['author_rep']) + if reputation < 1: + post['blacklists'].append('reputation-0') + elif reputation == 1: + post['blacklists'].append('reputation-1') + if 'community_title' in row and row['community_title']: post['community'] = row['category'] post['community_title'] = row['community_title'] @@ -239,7 +260,6 @@ def append_statistics_to_post(post, row, is_pinned): else: post['stats']['gray'] = row['is_grayed'] post['stats']['hide'] = 'irredeemables' in post['blacklists'] - if is_pinned: post['stats']['is_pinned'] = True return post @@ -291,9 +311,49 @@ async def get_account_posts(context, sort, account, start_author='', start_perml sql = sql % """ """ posts = [] + blacklists_for_user = None + if observer: + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) sql_result = await db.query_all(sql, account=account, author=start_author, permlink=start_permlink, limit=limit) for row in sql_result: post = _condenser_post_object(row) - post = append_statistics_to_post(post, row, False) + post = await append_statistics_to_post(post, row, False, blacklists_for_user) posts.append(post) return posts + +@return_error_info +async def get_relationship_between_accounts(context, account1, account2, observer=None): + valid_account(account1) + valid_account(account2) + + db = context['db'] + + sql = """ + SELECT state, blacklisted, follow_blacklists FROM hive_follows WHERE + follower = (SELECT id FROM hive_accounts WHERE name = :account1) AND + following = (SELECT id FROM hive_accounts WHERE name = :account2) + """ + + sql_result = await db.query_all(sql, account1=account1, account2=account2) + + result = { + 'follows': False, + 'ignores': False, + 'is_blacklisted': False, + 'follows_blacklists': False + } + + for row in sql_result: + state = row['state'] + if state == 1: + result['follows'] = True + elif state == 2: + result['ignores'] = True + + if row['blacklisted']: + result['is_blacklisted'] = True + if row['follow_blacklists']: + result['follows_blacklists'] = True + + return result + diff --git a/hive/server/bridge_api/thread.py b/hive/server/bridge_api/thread.py index f987d1918cc90d220b64173268390c0a74a30b50..532a250e7aba31d936bff6ad4f3b2880474bef98 100644 --- a/hive/server/bridge_api/thread.py +++ b/hive/server/bridge_api/thread.py @@ -8,11 +8,12 @@ from hive.server.common.helpers import ( return_error_info, valid_account, valid_permlink) +from hive.server.common.mutes import Mutes log = logging.getLogger(__name__) @return_error_info -async def get_discussion(context, author, permlink): +async def get_discussion(context, author, permlink, observer=None): """Modified `get_state` thread implementation.""" # New index was created: hive_posts_parent_id_btree (CREATE INDEX "hive_posts_parent_id_btree" ON hive_posts btree(parent_id) # We thougth this would be covered by "hive_posts_ix4" btree (parent_id, id) WHERE is_deleted = false but it was not @@ -22,11 +23,13 @@ async def get_discussion(context, author, permlink): permlink = valid_permlink(permlink) sql = """ - ---get_discussion - WITH RECURSIVE child_posts AS ( - SELECT id, parent_id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink) - UNION - SELECT children.id, children.parent_id FROM hive_posts children JOIN child_posts ON (children.parent_id = child_posts.id) + WITH RECURSIVE child_posts (id, parent_id) AS ( + SELECT id, parent_id FROM hive_posts WHERE author_id = (SELECT id FROM hive_accounts WHERE name = :author) + AND permlink_id = (SELECT id FROM hive_permlik_data WHERE permlink = :permlink) + AND NOT hp.is_deleted AND NOT hp.is_muted + UNION ALL + SELECT children.id, children.parent_id FROM hive_posts children INNER JOIN child_posts ON (children.parent_id = child_posts.id) + WHERE NOT children.is_deleted AND NOT children.is_muted ) SELECT child_posts.id, child_posts.parent_id, hive_posts.id, hive_accounts.name as author, hpd_p.permlink as permlink, hpd.title as title, hpd.body as body, hcd.category as category, hive_posts.depth, @@ -39,18 +42,22 @@ async def get_discussion(context, author, permlink): hive_posts.sc_trend AS sc_trend, hive_accounts.id AS acct_author_id FROM child_posts JOIN hive_accounts ON (hive_posts.author_id = hive_accounts.id) INNER JOIN hive_permlink_data hpd_p ON hpd_p.id = hive_posts.permlink_id - LEFT JOIN hive_post_data hpd ON hpd.id = hive_posts.id - LEFT JOIN hive_category_data hcd ON hcd.id = hp.category_id + INNER JOIN hive_post_data hpd ON hpd.id = hive_posts.id + INNER JOIN hive_category_data hcd ON hcd.id = hp.category_id WHERE NOT hive_posts.is_deleted AND NOT hive_posts.is_muted """ + blacklists_for_user = None + if observer: + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) + rows = await db.query_all(sql, author=author, permlink=permlink) if not rows or len(rows) == 0: return {} root_id = rows[0]['id'] all_posts = {} root_post = _condenser_post_object(rows[0]) - root_post = append_statistics_to_post(root_post, rows[0], False) + root_post = await append_statistics_to_post(root_post, rows[0], False, blacklists_for_user) root_post['replies'] = [] all_posts[root_id] = root_post @@ -60,7 +67,7 @@ async def get_discussion(context, author, permlink): for index in range(1, len(rows)): id_to_parent_id_map[rows[index]['id']] = rows[index]['parent_id'] post = _condenser_post_object(rows[index]) - post = append_statistics_to_post(post, rows[index], False) + post = await append_statistics_to_post(post, rows[index], False, blacklists_for_user) post['replies'] = [] all_posts[post['post_id']] = post diff --git a/hive/server/common/mutes.py b/hive/server/common/mutes.py index 1194708cade181705fbec51f246343e88e356c4c..53fc167778924a7d696f9a3e346f48f601d0b958 100644 --- a/hive/server/common/mutes.py +++ b/hive/server/common/mutes.py @@ -4,9 +4,25 @@ import logging from time import perf_counter as perf from urllib.request import urlopen, Request import ujson as json +from hive.server.common.helpers import valid_account +from hive.db.adapter import Db log = logging.getLogger(__name__) +GET_BLACKLISTED_ACCOUNTS_SQL = """ +WITH blacklisted_users AS ( + SELECT following, 'my_blacklist' AS source FROM hive_follows WHERE follower = + (SELECT id FROM hive_accounts WHERE name = :observer ) + AND blacklisted + UNION ALL + SELECT following, 'my_followed_blacklists' AS source FROM hive_follows WHERE follower IN + (SELECT following FROM hive_follows WHERE follower = + (SELECT id FROM hive_accounts WHERE name = :observer ) + AND follow_blacklists) AND blacklisted +) +SELECT following, source FROM blacklisted_users +""" + def _read_url(url): req = Request(url, headers={'User-Agent': 'Mozilla/5.0'}) return urlopen(req).read() @@ -20,6 +36,7 @@ class Mutes: blist = set() # list/any-blacklist blist_map = dict() # cached account-list map fetched = None + all_accounts = dict() @classmethod def instance(cls): @@ -46,6 +63,13 @@ class Mutes: jsn = _read_url(self.blacklist_api_url + "/blacklists") self.blist = set(json.loads(jsn)) log.warning("%d muted, %d blacklisted", len(self.accounts), len(self.blist)) + + self.all_accounts.clear() + sql = "select id, name from hive_accounts" + db = Db.instance() + sql_result = db.query_all(sql) + for row in sql_result: + self.all_accounts[row['id']] = row['name'] self.fetched = perf() @classmethod @@ -53,6 +77,27 @@ class Mutes: """Return the set of all muted accounts from singleton instance.""" return cls.instance().accounts + @classmethod + async def get_blacklists_for_observer(cls, observer=None, context=None): + """ fetch the list of users that the observer has blacklisted """ + if not observer or not context: + return {} + + if int(perf() - cls.instance().fetched) > 3600: + cls.instance().load() + + blacklisted_users = {} + + db = context['db'] + sql = GET_BLACKLISTED_ACCOUNTS_SQL + sql_result = await db.query_all(sql, observer=observer) + for row in sql_result: + account_name = cls.all_accounts[row['following']] + if account_name not in blacklisted_users: + blacklisted_users[account_name] = [] + blacklisted_users[account_name].append(row['source']) + return blacklisted_users + @classmethod def lists(cls, name, rep): """Return blacklists the account belongs to.""" diff --git a/hive/server/condenser_api/call.py b/hive/server/condenser_api/call.py index c6ba37d2855689afac3b9037ef0f673fd93f66ec..71f27d59fee0bcde30d7a1b54adeae21fe3f89f3 100644 --- a/hive/server/condenser_api/call.py +++ b/hive/server/condenser_api/call.py @@ -94,7 +94,7 @@ async def call(context, api, method, params): # Content primitives elif method == 'get_content': - return await get_content(context, *_strict_list(params, 2)) + return await get_content(context, *_strict_list(params, 3, 2)) elif method == 'get_content_replies': return await get_content_replies(context, *_strict_list(params, 2)) diff --git a/hive/server/condenser_api/methods.py b/hive/server/condenser_api/methods.py index cd94250e136ab56708effb9ffccbe7c6ccb354c2..eac4c0c69d579bb848e651b3d0d92a6bde651b6d 100644 --- a/hive/server/condenser_api/methods.py +++ b/hive/server/condenser_api/methods.py @@ -4,6 +4,7 @@ from functools import wraps import hive.server.condenser_api.cursor as cursor from hive.server.condenser_api.objects import load_posts, load_posts_reblogs, resultset_to_posts +from hive.server.condenser_api.objects import _mute_votes, _condenser_post_object from hive.server.common.helpers import ( ApiError, return_error_info, @@ -13,12 +14,12 @@ from hive.server.common.helpers import ( valid_offset, valid_limit, valid_follow_type) +from hive.server.common.mutes import Mutes # pylint: disable=too-many-arguments,line-too-long,too-many-lines SQL_TEMPLATE = """ SELECT hp.id, - community_id, ha_a.name as author, hpd_p.permlink as permlink, (SELECT title FROM hive_post_data WHERE hive_post_data.id = hp.id) as title, @@ -35,31 +36,18 @@ SQL_TEMPLATE = """ updated_at, rshares, (SELECT json FROM hive_post_data WHERE hive_post_data.id = hp.id) as json, + ha_a.reputation AS author_rep, is_hidden, is_grayed, total_votes, flag_weight, - ha_pa.name as parent_author, - hpd_pp.permlink as parent_permlink, - curator_payout_value, - ha_ra.name as root_author, - hpd_rp.permlink as root_permlink, - max_accepted_payout, - percent_hbd, - allow_replies, - allow_votes, - allow_curation_rewards, - beneficiaries, - url, - root_title, - ha_a.reputation AS author_rep + sc_trend, + author_id, + is_pinned + FROM hive_posts hp INNER JOIN hive_accounts ha_a ON ha_a.id = hp.author_id INNER JOIN hive_permlink_data hpd_p ON hpd_p.id = hp.permlink_id - INNER JOIN hive_accounts ha_pa ON ha_pa.id = hp.parent_author_id - INNER JOIN hive_permlink_data hpd_pp ON hpd_pp.id = hp.parent_permlink_id - INNER JOIN hive_accounts ha_ra ON ha_ra.id = hp.root_author_id - INNER JOIN hive_permlink_data hpd_rp ON hpd_rp.id = hp.root_permlink_id WHERE """ @@ -140,7 +128,7 @@ async def get_account_reputations(context, account_lower_bound: str = None, limi # Content Primitives @return_error_info -async def get_content(context, author: str, permlink: str): +async def get_content(context, author: str, permlink: str, observer=None): """Get a single post object.""" db = context['db'] valid_account(author) @@ -149,10 +137,16 @@ async def get_content(context, author: str, permlink: str): sql = str(SQL_TEMPLATE) sql += """ WHERE ha_a.name = :author AND hpd_p.permlink = :permlink AND NOT hp.is_deleted """ + post = None result = await db.query_all(sql, author=author, permlink=permlink) - result = dict(result[0]) - post = _condenser_post_object(result, 0) - post['active_votes'] = _mute_votes(post['active_votes'], Mutes.all()) + if result: + result = dict(result[0]) + post = _condenser_post_object(result, 0) + if not observer: + post['active_votes'] = _mute_votes(post['active_votes'], Mutes.all()) + else: + blacklists_for_user = await Mutes.get_blacklists_for_observer(observer, context) + post['active_votes'] = _mute_votes(post['active_votes'], blacklists_for_user.keys()) assert post, 'post was not found in cache' return post diff --git a/hive/server/serve.py b/hive/server/serve.py index 6b7ecad02cd84ee0ba89640e6d4c590a087e826a..ad75d2c0d6634e08e762cef19a314e23b79bb609 100644 --- a/hive/server/serve.py +++ b/hive/server/serve.py @@ -137,6 +137,7 @@ def build_methods(): bridge_api.get_ranked_posts, bridge_api.get_profile, bridge_api.get_trending_topics, + bridge_api.get_relationship_between_accounts, hive_api_notify.post_notifications, hive_api_notify.account_notifications, hive_api_notify.unread_notifications, diff --git a/query_hivemind_capture_times.sh b/query_hivemind_capture_times.sh new file mode 100755 index 0000000000000000000000000000000000000000..3d2ffe764fe000f46d19ec99b1d67679b862d7c0 --- /dev/null +++ b/query_hivemind_capture_times.sh @@ -0,0 +1,170 @@ +#!/bin/bash + +HOST=127.0.0.1:8085 + +echo "condenser_api.get_content" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":1, "method":"condenser_api.get_content", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":2, "method":"condenser_api.get_content", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":3, "method":"condenser_api.get_content", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_content_replies" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":4, "method":"condenser_api.get_content_replies", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":5, "method":"condenser_api.get_content_replies", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":6, "method":"condenser_api.get_content_replies", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_trending" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_trending", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":8, "method":"condenser_api.get_discussions_by_trending", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":9, "method":"condenser_api.get_discussions_by_trending", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_hot" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_hot", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_hot", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_hot", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_promoted" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_promoted", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_promoted", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_promoted", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_created" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_created", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_created", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_created", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_blog" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_blog", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_blog", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_blog", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_feed" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_feed", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_feed", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_discussions_by_feed", "params":{"tag":"blocktrades"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_discussions_by_comments" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":1, "method":"condenser_api.get_discussions_by_comments", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":1, "method":"condenser_api.get_discussions_by_comments", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":1, "method":"condenser_api.get_discussions_by_comments", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_post_discussions_by_payout" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_post_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_post_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_post_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "condenser_api.get_comment_discussions_by_payout" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_comment_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_comment_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"condenser_api.get_comment_discussions_by_payout", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_profile" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_profile", "params":{"account":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_profile", "params":{"account":"blocktrades"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_profile", "params":{"account":"blocktrades"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_trending_topics" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_trending_topics", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_trending_topics", "params":{}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_trending_topics", "params":{}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_post" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_post", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_post", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_post", "params":{"author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (trending)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"trending"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"trending"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"trending"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (hot)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"hot"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"hot"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"hot"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (created)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"created"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"created"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"created"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (promoted)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"promoted"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"promoted"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"promoted"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (payout)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (payout_comments)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout_comments"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout_comments"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"payout_comments"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_ranked_posts (muted)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"muted"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"muted"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_ranked_posts", "params":{"sort":"muted"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_account_posts (blog)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"blog"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"blog"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"blog"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_account_posts (feed)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"feed"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"feed"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"feed"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bride.get_account_posts (posts)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"posts"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"posts"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"posts"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_account_posts (comments)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"comments"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"comments"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"comments"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_account_posts (replies)" >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"replies"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"replies"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"replies"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo "bridge.get_account_posts (payout) " >> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"payout"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"payout"}}' $HOST ; } 2>> query_times.log +{ time curl -s -d '{"jsonrpc":"2.0", "id":7, "method":"bridge.get_account_posts", "params":{"account":"blocktrades", "sort":"payout"}}' $HOST ; } 2>> query_times.log +echo "" >> query_times.log + +echo +echo +echo +echo "All done!" diff --git a/run_hivemind_test_queries.sh b/run_hivemind_test_queries.sh new file mode 100755 index 0000000000000000000000000000000000000000..08a91eb87adccc43d8313b29a998ccd44f756ef1 --- /dev/null +++ b/run_hivemind_test_queries.sh @@ -0,0 +1,299 @@ +#!/bin/bash + +echo "test get_content (REQUIRED params: author, permlink; OPTIONAL params: none)" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_content","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr-purr"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_content","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr-purr"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_content_replies (REQUIRED params: author, permlink; OPTIONAL params: none)" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_content_replies","params":{"author":"blocktrades", "permlink":"should-long-term-hive-proposals-cost-more-to-create"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_content_replies","params":{"author":"blocktrades", "permlink":"should-long-term-hive-proposals-cost-more-to-create"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_trending no params (REQUIRED params: none; OPTIONAL params: start_author, start_permlink, limit, tag, truncate_body, filter_tags)" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_trending author and permlink (REQUIRED params: none; OPTIONAL params: start_author, start_permlink, limit, tag, truncate_body, filter_tags)" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{"start_author":"blocktrades", "start_permlink":"should-long-term-hive-proposals-cost-more-to-create"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{"start_author":"blocktrades", "start_permlink":"should-long-term-hive-proposals-cost-more-to-create"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_trending with tag(REQUIRED params: none; OPTIONAL params: start_author, start_permlink, limit, tag, truncate_body, filter_tags)" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{"tag":"gaming"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_trending","params":{"tag":"gaming"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_hot" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_hot","params":{} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_hot","params":{} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_promoted" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_promoted","params":{} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_promoted","params":{} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_created" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_created","params":{} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_created","params":{} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_blog" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_blog","params":{"tag":"blocktrades"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_blog","params":{"tag":"blocktrades"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_feed" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_feed","params":{"tag":"blocktrades"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_feed","params":{"tag":"blocktrades"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_discussions_by_comments" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_comments","params":{"start_author":"blocktrades"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"condenser_api.get_discussions_by_comments","params":{"start_author":"blocktrades"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test trending" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test hot" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test created" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test promoted" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout_comments" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test muted" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test trending with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "start_author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "start_author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test hot with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test created with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test promoted with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout comments with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test muted with author and permlink" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test trending with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test hot with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test created with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test promoted with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout comments with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":"all"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test muted with author and permlink and tag of all" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":""} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "author":"blocktrades", "permlink":"image-server-cluster-development-and-maintenance", "tag":""} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +#-------------------------------------------------------------------------------------------------------- +echo "RANKED POSTS" +echo "" + +echo "test trending with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"trending", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test hot with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"hot", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test created with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"created", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test promoted with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"promoted", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test payout comments with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"payout_comments", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test muted with no author/permlink but with tag" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"muted", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test with garbage params, should fail but not crash out" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"mutead", "limit":5, "tag":"games"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_ranked_posts","params":{"sort":"mutead", "limit":5, "tag":"games"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_post" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_post","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr-purr"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_post","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr-purr"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json + +echo "test get_post with garbage. should fail but not crash out" +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_post","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr"} }' http://steem-3:8085 > old_result +curl -s -d '{"jsonrpc":"2.0","id":1,"method":"bridge.get_post","params":{"author":"jes2850", "permlink":"happy-kitty-sleepy-kitty-purr-purr"} }' http://127.0.0.1:8085 > new_result +cat old_result | jq . > old_pretty.json +cat new_result | jq . > new_pretty.json +diff old_pretty.json new_pretty.json