Skip to content

Commit

Permalink
filter mutes from recent replies, fix #200
Browse files Browse the repository at this point in the history
  • Loading branch information
roadscape committed Mar 27, 2019
1 parent cd78b95 commit c169f12
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions hive/server/condenser_api/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
from dateutil.relativedelta import relativedelta

from hive.utils.normalize import rep_to_raw
from hive.server.common.mutes import Mutes

MUTES = Mutes.all()

#pylint: disable=too-many-lines

def last_month():
"""Get the date 1 month ago."""
Expand Down Expand Up @@ -114,6 +119,7 @@ async def pids_by_query(db, sort, start_author, start_permlink, limit, tag):
`sort` can be trending, hot, created, promoted, payout, or payout_comments.
"""
#pylint: disable=too-many-arguments
assert sort in ['trending', 'hot', 'created', 'promoted',
'payout', 'payout_comments']

Expand Down Expand Up @@ -316,7 +322,8 @@ async def pids_by_account_comments(db, account: str, start_permlink: str = '', l
return await db.query_col(sql, account=account, start_id=start_id, limit=limit)


async def pids_by_replies_to_account(db, start_author: str, start_permlink: str = '', limit: int = 20):
async def pids_by_replies_to_account(db, start_author: str, start_permlink: str = '',
limit: int = 20):
"""Get a list of post_ids representing replies to an author.
To get the first page of results, specify `start_author` as the
Expand Down Expand Up @@ -346,16 +353,21 @@ async def pids_by_replies_to_account(db, start_author: str, start_permlink: str
else:
parent_account = start_author

mute = ''
if MUTES:
mute = " AND author NOT IN :mutes"

sql = """
SELECT id FROM hive_posts
WHERE parent_id IN (SELECT id FROM hive_posts
WHERE author = :parent
AND is_deleted = '0'
ORDER BY id DESC
LIMIT 10000) %s
AND is_deleted = '0'
AND is_deleted = '0' %s
ORDER BY id DESC
LIMIT :limit
""" % seek
""" % (seek, mute)

return await db.query_col(sql, parent=parent_account, start_id=start_id, limit=limit)
return await db.query_col(sql, parent=parent_account, start_id=start_id,
limit=limit, mutes=tuple(MUTES))

0 comments on commit c169f12

Please sign in to comment.