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
Showing with 143 additions and 133 deletions
......@@ -304,21 +304,25 @@ WHERE NOT EXISTS (SELECT data_type
--- Notification cache to significantly speedup notification APIs.
CREATE TABLE IF NOT EXISTS hive_notification_cache
(
id BIGINT NOT NULL,
block_num INT NOT NULL,
type_id INT NOT NULL,
dst INT NULL,
src INT NULL,
dst_post_id INT NULL,
post_id INT NULL,
score INT NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
community_title VARCHAR(32) NULL,
community VARCHAR(16) NULL,
payload VARCHAR NULL,
CONSTRAINT hive_notification_cache_pk PRIMARY KEY (id)
id BIGINT NOT NULL,
block_num INT NOT NULL,
type_id INT NOT NULL,
dst INT NULL,
src INT NULL,
dst_post_id INT NULL,
post_id INT NULL,
score INT NOT NULL,
created_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
community_title VARCHAR(32) NULL,
community VARCHAR(16) NULL,
payload VARCHAR NULL,
CONSTRAINT hive_notification_cache_pk PRIMARY KEY (id)
);
CREATE INDEX IF NOT EXISTS hive_notification_cache_block_num_idx ON hive_notification_cache (block_num);
CREATE INDEX IF NOT EXISTS hive_notification_cache_dst_score_idx ON hive_notification_cache (dst, score) WHERE dst IS NOT NULL;
CREATE INDEX IF NOT EXISTS hive_feed_cache_block_num_idx on hive_feed_cache (block_num);
CREATE INDEX IF NOT EXISTS hive_feed_cache_created_at_idx on hive_feed_cache (created_at);
......@@ -12,7 +12,6 @@ from hive.server.hive_api.common import get_account_id
from hive.server.hive_api.objects import _follow_contexts
from hive.server.hive_api.community import list_top_communities
from hive.server.common.mutes import Mutes
from hive.server.hive_api.public import get_by_feed_with_reblog_impl
#pylint: disable=too-many-arguments, no-else-return
......@@ -117,7 +116,7 @@ async def _get_ranked_posts_for_communities( db, sort:str, community, start_auth
if sort == 'trending':
result_with_pinned_posts = []
sql = "SELECT * FROM bridge_get_ranked_post_by_trends_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_trends_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, True )"
result_with_pinned_posts = await execute_community_query(db, pinned_sql, limit)
limit -= len(result_with_pinned_posts)
if limit > 0:
......@@ -129,7 +128,7 @@ async def _get_ranked_posts_for_communities( db, sort:str, community, start_auth
return await execute_community_query(db, sql, limit)
if sort == 'created':
sql = "SELECT * FROM bridge_get_ranked_post_by_created_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_created_for_community( (:community)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, True )"
result_with_pinned_posts = await execute_community_query(db, pinned_sql, limit)
limit -= len(result_with_pinned_posts)
if limit > 0:
......@@ -165,7 +164,7 @@ async def _get_ranked_posts_for_tag( db, sort:str, tag, start_author:str, start_
return await execute_tags_query(db, sql, limit)
if sort == 'payout':
sql = "SELECT * FROM bridge_get_ranked_post_by_payout_for_category( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_payout_for_category( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, True )"
return await execute_tags_query(db, sql, limit)
if sort == 'payout_comments':
......@@ -208,7 +207,7 @@ async def _get_ranked_posts_for_all( db, sort:str, start_author:str, start_perml
return await execute_query(db, sql, limit)
if sort == 'payout':
sql = "SELECT * FROM bridge_get_ranked_post_by_payout( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_payout( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, True )"
return await execute_query(db, sql, limit)
if sort == 'payout_comments':
......@@ -263,9 +262,6 @@ async def get_ranked_posts(context, sort:str, start_author:str='', start_permlin
result = await _get_ranked_posts_for_all(db, sort, start_author, start_permlink, limit)
return await process_query_results(result)
async def _get_account_posts_by_feed(db, account : str, start_author : str, start_permlink : str, limit : int):
return await get_by_feed_with_reblog_impl(db, account, start_author, start_permlink, limit)
@return_error_info
async def get_account_posts(context, sort:str, account:str, start_author:str='', start_permlink:str='',
limit:int=20, observer:str=None):
......@@ -286,7 +282,7 @@ async def get_account_posts(context, sort:str, account:str, start_author:str='',
if sort == 'blog':
sql = "SELECT * FROM bridge_get_account_posts_by_blog( (:account)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::INTEGER )"
elif sort == 'feed':
return await _get_account_posts_by_feed(db, account, start_author, start_permlink, limit)
sql = "SELECT * FROM bridge_get_by_feed_with_reblog((:account)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::INTEGER)"
elif sort == 'posts':
sql = "SELECT * FROM bridge_get_account_posts_by_posts( (:account)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'comments':
......@@ -310,8 +306,16 @@ async def get_account_posts(context, sort:str, account:str, start_author:str='',
post = _bridge_post_object(row)
post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.BridgeApi)
if sort == 'blog':
if post['author'] != account:
post['reblogged_by'] = [account]
if post['author'] != account:
post['reblogged_by'] = [account]
elif sort == 'feed':
reblogged_by = set(row['reblogged_by'])
reblogged_by.discard(row['author']) # Eliminate original author of reblogged post
if reblogged_by:
reblogged_by_list = list(reblogged_by)
reblogged_by_list.sort()
post['reblogged_by'] = reblogged_by_list
post = append_statistics_to_post(post, row, False if account_posts else row['is_pinned'], blacklists_for_user, not account_posts)
posts.append(post)
return posts
......
......@@ -155,8 +155,10 @@ def valid_offset(offset, ubound=None):
def valid_follow_type(follow_type: str):
"""Ensure follow type is valid steemd type."""
assert follow_type in ['blog', 'ignore'], 'invalid follow_type `%s`' % follow_type
return follow_type
# ABW: should be extended with blacklists etc. (and those should be implemented as next 'state' values)
supported_follow_types = dict(blog=1, ignore=2)
assert follow_type in supported_follow_types, "Unsupported follow type, valid types: {}".format(", ".join(supported_follow_types.keys()))
return supported_follow_types[follow_type]
def valid_date(date, allow_empty=False):
""" Ensure that date is in correct format """
......
......@@ -7,24 +7,16 @@ from hive.server.database_api.methods import find_votes_impl, VotesPresentation
# pylint: disable=too-many-lines
async def get_followers(db, account: str, start: str, follow_type: str, limit: int):
"""Get a list of accounts following by a given account."""
state = 2 if follow_type == 'ignore' else 1
sql = " SELECT * FROM condenser_get_names_by_followers( '{}', '{}', {}::SMALLINT, {}::SMALLINT ) ".format( account, start, state, limit )
async def get_followers(db, account: str, start: str, state: int, limit: int):
"""Get a list of accounts following given account."""
sql = "SELECT * FROM condenser_get_followers( (:account)::VARCHAR, (:start)::VARCHAR, :type, :limit )"
return await db.query_col(sql, account=account, start=start, type=state, limit=limit)
return await db.query_col(sql)
async def get_following(db, account: str, start: str, follow_type: str, limit: int):
async def get_following(db, account: str, start: str, state: int, limit: int):
"""Get a list of accounts followed by a given account."""
state = 2 if follow_type == 'ignore' else 1
sql = " SELECT * FROM condenser_get_names_by_following( '{}', '{}', {}::SMALLINT, {}::SMALLINT ) ".format( account, start, state, limit )
return await db.query_col(sql)
sql = "SELECT * FROM condenser_get_following( (:account)::VARCHAR, (:start)::VARCHAR, :type, :limit )"
return await db.query_col(sql, account=account, start=start, type=state, limit=limit)
async def get_follow_counts(db, account: str):
"""Return following/followers count for `account`."""
sql = "SELECT * FROM condenser_get_follow_counts( '{}' )".format( account )
return dict (await db.query_row(sql) )
async def get_reblogged_by(db, author: str, permlink: str):
"""Return all rebloggers of a post."""
......
......@@ -26,9 +26,7 @@ from hive.server.condenser_api.tags import (
import hive.server.condenser_api.cursor as cursor
from hive.server.condenser_api.methods import get_posts_by_given_sort
from hive.server.hive_api.public import get_by_feed_with_reblog_impl
from hive.server.condenser_api.methods import get_posts_by_given_sort, get_discussions_by_feed_impl
from hive.server.database_api.methods import find_votes_impl, VotesPresentation
log = logging.getLogger(__name__)
......@@ -170,7 +168,7 @@ async def _get_account_discussion_by_key(db, account, key):
elif key == 'blog':
posts = await cursor.get_by_blog(db, account, '', '', 20)
elif key == 'feed':
posts = await get_by_feed_with_reblog_impl(db, account, '', '', 20)
posts = await get_discussions_by_feed_impl(db, account, '', '', 20)
else:
raise ApiError("unknown account discussion key %s" % key)
......
......@@ -16,8 +16,6 @@ from hive.server.common.helpers import (
from hive.server.common.mutes import Mutes
from hive.server.database_api.methods import find_votes_impl, VotesPresentation
from hive.server.hive_api.public import get_by_feed_with_reblog_impl
# pylint: disable=too-many-arguments,line-too-long,too-many-lines
@return_error_info
......@@ -33,8 +31,8 @@ def _legacy_follower(follower, following, follow_type):
return dict(follower=follower, following=following, what=[follow_type])
@return_error_info
async def get_followers(context, account: str, start: str, follow_type: str = None,
limit: int = None, **kwargs):
async def get_followers(context, account: str, start: str = '', follow_type: str = None,
limit: int = 1000, **kwargs):
"""Get all accounts following `account`. (EOL)"""
# `type` reserved word workaround
if not follow_type and 'type' in kwargs:
......@@ -46,12 +44,12 @@ async def get_followers(context, account: str, start: str, follow_type: str = No
valid_account(account),
valid_account(start, allow_empty=True),
valid_follow_type(follow_type),
valid_limit(limit, 1000, None))
valid_limit(limit, 1000, 1000))
return [_legacy_follower(name, account, follow_type) for name in followers]
@return_error_info
async def get_following(context, account: str, start: str, follow_type: str = None,
limit: int = None, **kwargs):
async def get_following(context, account: str, start: str = '', follow_type: str = None,
limit: int = 1000, **kwargs):
"""Get all accounts `account` follows. (EOL)"""
# `type` reserved word workaround
if not follow_type and 'type' in kwargs:
......@@ -63,18 +61,19 @@ async def get_following(context, account: str, start: str, follow_type: str = No
valid_account(account),
valid_account(start, allow_empty=True),
valid_follow_type(follow_type),
valid_limit(limit, 1000, None))
valid_limit(limit, 1000, 1000))
return [_legacy_follower(account, name, follow_type) for name in following]
@return_error_info
async def get_follow_count(context, account: str):
"""Get follow count stats. (EOL)"""
count = await cursor.get_follow_counts(
context['db'],
valid_account(account))
db = context['db']
account = valid_account(account)
sql = "SELECT * FROM condenser_get_follow_count( (:account)::VARCHAR )"
counters = await db.query_row(sql, account=account)
return dict(account=account,
following_count=count['following'],
follower_count=count['followers'])
following_count=counters[0],
follower_count=counters[1])
@return_error_info
async def get_reblogged_by(context, author: str, permlink: str):
......@@ -91,7 +90,8 @@ async def get_account_reputations(context, account_lower_bound: str = None, limi
async def _get_account_reputations_impl(db, fat_node_style, account_lower_bound, limit):
"""Enumerate account reputations."""
limit = valid_limit(limit, 1000, None)
assert isinstance(account_lower_bound, str), "invalid account_lower_bound type"
limit = valid_limit(limit, 1000, 1000)
sql = "SELECT * FROM condenser_get_account_reputations( '{}', {}, {} )".format( account_lower_bound, account_lower_bound is None, limit )
rows = await db.query_all(sql, start=account_lower_bound, limit=limit)
......@@ -193,39 +193,56 @@ async def get_posts_by_given_sort(context, sort: str, start_author: str = '', st
tag = valid_tag(tag, allow_empty=True)
posts = []
is_community = tag[:5] == 'hive-'
if sort == 'created':
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_created_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if is_community:
sql = "SELECT * FROM bridge_get_ranked_post_by_created_for_community( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, False )"
elif tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_created( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_created( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_created_for_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'trending':
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_trending_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if is_community:
sql = "SELECT * FROM bridge_get_ranked_post_by_trends_for_community( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, False )"
elif tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_trends( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_trending( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_trends_for_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'hot':
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_hot_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if is_community:
sql = "SELECT * FROM bridge_get_ranked_post_by_hot_for_community( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_hot( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_hot( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_hot_for_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'promoted':
if tag == '':
sql = "SELECT * FROM condenser_get_discussions_by_promoted_with_empty_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if is_community:
sql = "SELECT * FROM bridge_get_ranked_post_by_promoted_for_community( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_promoted( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM condenser_get_discussions_by_promoted( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
sql = "SELECT * FROM bridge_get_ranked_post_by_promoted_for_tag( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
elif sort == 'post_by_payout':
sql = "SELECT * FROM condenser_get_post_discussions_by_payout( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_payout( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, False )"
else:
sql = "SELECT * FROM bridge_get_ranked_post_by_payout_for_category( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT, False )"
elif sort == 'comment_by_payout':
sql = "SELECT * FROM condenser_get_comment_discussions_by_payout( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
if tag == '':
sql = "SELECT * FROM bridge_get_ranked_post_by_payout_comments( (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
sql = "SELECT * FROM bridge_get_ranked_post_by_payout_comments_for_category( (:tag)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::SMALLINT )"
else:
return posts
sql_result = await db.query_all(sql, tag=tag, author=start_author, permlink=start_permlink, limit=limit )
muted_accounts = Mutes.all()
for row in sql_result:
post = _condenser_post_object(row, truncate_body)
post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi)
post['active_votes'] = _mute_votes(post['active_votes'], muted_accounts)
posts.append(post)
return posts
......@@ -302,6 +319,29 @@ async def get_discussions_by_blog(context, tag: str = None, start_author: str =
return posts_by_id
async def get_discussions_by_feed_impl(db, account: str, start_author: str = '',
start_permlink: str = '', limit: int = 20, truncate_body: int = 0):
"""Get a list of posts for an account's feed."""
sql = "SELECT * FROM bridge_get_by_feed_with_reblog((:account)::VARCHAR, (:author)::VARCHAR, (:permlink)::VARCHAR, (:limit)::INTEGER)"
result = await db.query_all(sql, account=account, author=start_author, permlink=start_permlink, limit=limit)
posts = []
for row in result:
row = dict(row)
post = _condenser_post_object(row, truncate_body=truncate_body)
reblogged_by = set(row['reblogged_by'])
reblogged_by.discard(row['author']) # Eliminate original author of reblogged post
if reblogged_by:
reblogged_by_list = list(reblogged_by)
reblogged_by_list.sort()
post['reblogged_by'] = reblogged_by_list
post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi)
posts.append(post)
return posts
@return_error_info
@nested_query_compat
async def get_discussions_by_feed(context, tag: str = None, start_author: str = '',
......@@ -310,7 +350,7 @@ async def get_discussions_by_feed(context, tag: str = None, start_author: str =
"""Retrieve account's personalized feed."""
assert tag, '`tag` cannot be blank'
assert not filter_tags, 'filter_tags not supported'
return await get_by_feed_with_reblog_impl(
return await get_discussions_by_feed_impl(
context['db'],
valid_account(tag),
valid_account(start_author, allow_empty=True),
......
......@@ -7,16 +7,7 @@ from hive.server.common.helpers import (return_error_info, valid_tag, valid_limi
@cached(ttl=7200, timeout=1200)
async def get_top_trending_tags_summary(context):
"""Get top 50 trending tags among pending posts."""
# Same results, more overhead:
#return [tag['name'] for tag in await get_trending_tags('', 50)]
sql = """
SELECT (SELECT category FROM hive_category_data WHERE id = category_id) as category
FROM hive_posts
WHERE counter_deleted = 0 AND NOT is_paidout
GROUP BY category
ORDER BY SUM(payout + pending_payout) DESC
LIMIT 50
"""
sql = "SELECT condenser_get_top_trending_tags_summary(50)"
return await context['db'].query_col(sql)
@return_error_info
......@@ -27,32 +18,10 @@ async def get_trending_tags(context, start_tag: str = '', limit: int = 250):
limit = valid_limit(limit, 250, 250)
start_tag = valid_tag(start_tag or '', allow_empty=True)
if start_tag:
seek = """
HAVING SUM(payout + pending_payout) <= (
SELECT SUM(payout + pending_payout)
FROM hive_posts hp
JOIN hive_category_data hcd ON hcd.id = hp.category_id
WHERE NOT is_paidout AND counter_deleted = 0 AND hcd.category = :start_tag)
"""
else:
seek = ''
sql = """
SELECT hcd.category,
COUNT(*) AS total_posts,
SUM(CASE WHEN hp.depth = 0 THEN 1 ELSE 0 END) AS top_posts,
SUM(hp.payout + hp.pending_payout) AS total_payouts
FROM hive_posts hp
JOIN hive_category_data hcd ON hcd.id = hp.category_id
WHERE NOT hp.is_paidout AND counter_deleted = 0
GROUP BY hcd.category %s
ORDER BY SUM(hp.payout + hp.pending_payout) DESC, hcd.category ASC
LIMIT :limit
""" % seek
sql = "SELECT * FROM condenser_get_trending_tags( (:tag)::VARCHAR, :limit )"
out = []
for row in await context['db'].query_all(sql, limit=limit, start_tag=start_tag):
for row in await context['db'].query_all(sql, limit=limit, tag=start_tag):
out.append({
'name': row['category'],
'comments': row['total_posts'] - row['top_posts'],
......
......@@ -10,9 +10,6 @@ from hive.server.condenser_api.cursor import get_followers, get_following
from hive.db.schema import DB_VERSION as SCHEMA_DB_VERSION
from hive.server.condenser_api.objects import _condenser_post_object
from hive.server.database_api.methods import find_votes_impl, VotesPresentation
log = logging.getLogger(__name__)
# Accounts
......@@ -44,7 +41,8 @@ async def list_followers(context, account:str, start:str='', limit:int=50, obser
context['db'],
valid_account(account),
valid_account(start, allow_empty=True),
'blog', valid_limit(limit, 100, 50))
1, # blog
valid_limit(limit, 100, 50))
return await accounts_by_name(context['db'], followers, observer, lite=True)
async def list_following(context, account:str, start:str='', limit:int=50, observer:str=None):
......@@ -53,7 +51,8 @@ async def list_following(context, account:str, start:str='', limit:int=50, obser
context['db'],
valid_account(account),
valid_account(start, allow_empty=True),
'blog', valid_limit(limit, 100, 50))
1, # blog
valid_limit(limit, 100, 50))
return await accounts_by_name(context['db'], following, observer, lite=True)
async def list_all_muted(context, account):
......@@ -80,19 +79,3 @@ async def get_info(context):
}
return ret
async def get_by_feed_with_reblog_impl(db, account: str, start_author: str = '',
start_permlink: str = '', limit: int = 20, truncate_body: int = 0):
"""Get a list of posts for an account's feed."""
sql = " SELECT * FROM condenser_get_by_feed_with_reblog( '{}', '{}', '{}', {} ) ".format( account, start_author, start_permlink, limit )
result = await db.query_all(sql)
posts = []
for row in result:
row = dict(row)
post = _condenser_post_object(row, truncate_body=truncate_body)
post['active_votes'] = await find_votes_impl(db, row['author'], row['permlink'], VotesPresentation.CondenserApi)
posts.append(post)
return posts
......@@ -106,6 +106,7 @@ def build_methods():
'follow_api.get_blog': condenser_api.get_blog,
'follow_api.get_blog_entries': condenser_api.get_blog_entries,
'follow_api.get_reblogged_by': condenser_api.get_reblogged_by,
# three functions under are not implemented, should we remove them?
'follow_api.get_feed_entries': follow_api.get_feed_entries,
'follow_api.get_feed': follow_api.get_feed,
'follow_api.get_blog_authors': follow_api.get_blog_authors
......@@ -125,6 +126,7 @@ def build_methods():
'tags_api.get_post_discussions_by_payout': condenser_api.get_post_discussions_by_payout,
'tags_api.get_comment_discussions_by_payout': condenser_api.get_comment_discussions_by_payout,
'tags_api.get_active_votes' : tags_api.get_active_votes,
# five functions under are not implemented, should we remove them?
'tags_api.get_tags_used_by_author' : tags_api.get_tags_used_by_author,
'tags_api.get_discussions_by_active' : tags_api.get_discussions_by_active,
'tags_api.get_discussions_by_cashout' : tags_api.get_discussions_by_cashout,
......
......@@ -5,6 +5,8 @@ pip install tox
export HIVEMIND_ADDRESS=$1
export HIVEMIND_PORT=$2
export TAVERN_DIR="tests/tests_api/hivemind/tavern"
echo "Starting tests on hivemind server running on ${HIVEMIND_ADDRESS}:${HIVEMIND_PORT}"
echo "Selected test group (if empty all will be executed): $3"
......
......@@ -5,6 +5,8 @@ pip3 install tox --user
export HIVEMIND_ADDRESS=$1
export HIVEMIND_PORT=$2
export TAVERN_DIR="tests/tests_api/hivemind/tavern"
echo Attempting to start tests on hivemind instance listeing on: $HIVEMIND_ADDRESS port: $HIVEMIND_PORT
echo "Selected test group (if empty all will be executed): $3"
......
#!/bin/bash
# script to run tavern tests for full sync hivemind node
export TAVERN_DIR="tests/tests_api/hivemind/tavern_full_sync"
SCRIPT=$(readlink -f "$0")
$(dirname "$SCRIPT")/run_tests.sh "$@"
......@@ -63,7 +63,10 @@ pip3 install tox --user
export HIVEMIND_ADDRESS=$1
export HIVEMIND_PORT=$2
if [ -z "$TAVERN_DIR" ]
then
export TAVERN_DIR="tests/tests_api/hivemind/tavern"
fi
echo "Attempting to start tests on hivemind instance listening on: $HIVEMIND_ADDRESS port: $HIVEMIND_PORT"
echo "Additional test options: ${@:3}"
......
Subproject commit 1ae2a4b1367139e7954b31596eaa4bf65e6aa68e
Subproject commit 1cb3c40848344e3f143528c0d4127cd68c2029dd
......@@ -24,7 +24,7 @@ passenv =
HIVEMIND_ADDRESS
HIVEMIND_PORT
changedir = tests/tests_api/hivemind/tavern
changedir = {env:TAVERN_DIR}
deps =
{[testenv]deps}
......