Skip to content

Commit

Permalink
remove debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
ety001 committed Sep 4, 2024
1 parent 6b488a0 commit 15b6cd4
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions hive/server/bridge_api/cursor.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
"""Cursor-based pagination queries, mostly supporting bridge_api."""

import logging
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta

# pylint: disable=too-many-lines

log = logging.getLogger(__name__)
DEFAULT_CID = 1317453
PAYOUT_WINDOW = "now() + interval '12 hours' AND now() + interval '36 hours'"

Expand Down Expand Up @@ -54,74 +52,44 @@ async def pids_by_ranked(db, sort, start_author, start_permlink, limit, tag, obs
cids = None
single = None
if tag == 'my':
t0 = datetime.now()
cids = await _subscribed(db, observer_id)
t1 = datetime.now()
exec_time = (t1 - t0).total_seconds()
log.info("pids_by_ranked_t1: %d s." % exec_time)
if not cids: return []
elif tag == 'all':
cids = []
elif tag[:5] == 'hive-':
t0 = datetime.now()
single = await _get_community_id(db, tag)
t1 = datetime.now()
exec_time = (t1 - t0).total_seconds()
log.info("pids_by_ranked_t1: %d s." % exec_time)
if single: cids = [single]

# if tag was comms key, then no tag filter
if cids is not None: tag = None

start_id = None
if start_permlink:
t0 = datetime.now()
start_id = await _get_post_id(db, start_author, start_permlink)
t2 = datetime.now()
exec_time = (t2 - t0).total_seconds()
log.info("pids_by_ranked_t2: %d s." % exec_time)

t0 = datetime.now()
if cids is None:
pids = await pids_by_category(db, tag, sort, start_id, limit)
t3 = datetime.now()
else:
pids = await pids_by_community(db, cids, sort, start_id, limit)
t3 = datetime.now()
exec_time = (t3 - t0).total_seconds()
log.info("pids_by_ranked_t3: %d s." % exec_time)


# if not filtered by tag, is first page trending: prepend pinned
if not tag and not start_id and sort in ('trending', 'created'):
t0 = datetime.now()
prepend = await _pinned(db, single or DEFAULT_CID)
t4 = datetime.now()
exec_time = (t4 - t0).total_seconds()
log.info("pids_by_ranked_t4: %d s." % exec_time)
for pid in prepend:
if pid in pids:
pids.remove(pid)
pids = prepend + pids

# first page prepend pinned
if not tag and not cids and not start_id and sort in ('trending', 'created'):
t0 = datetime.now()
first_prepend = await _pids_by_type(db, '2')
t5 = datetime.now()
exec_time = (t5 - t0).total_seconds()
log.info("pids_by_ranked_t5: %d s." % exec_time)
for pid in first_prepend:
if pid in pids:
pids.remove(pid)
pids = first_prepend + pids

# hide posts
t0 = datetime.now()
hide_pids = await hide_pids_by_ids(db, pids)
t6 = datetime.now()
exec_time = (t6 - t0).total_seconds()
log.info("pids_by_ranked_t6: %d s." % exec_time)
for pid in hide_pids:
if pid in pids:
pids.remove(pid)
Expand Down Expand Up @@ -197,7 +165,6 @@ async def pids_by_community(db, ids, sort, seek_id, limit):
ORDER BY %s DESC, post_id LIMIT :limit
""" % (table, ' AND '.join(where), field))

log.info(f"pids_by_community: {sql}")
# execute
return await db.query_col(sql, ids=tuple(ids), seek_id=seek_id, limit=limit)

Expand Down Expand Up @@ -259,7 +226,6 @@ async def pids_by_category(db, tag, sort, last_id, limit):
ORDER BY %s DESC, post_id LIMIT :limit
""" % (table, ' AND '.join(where), field))

log.info(f"pids_by_category: {sql}")
return await db.query_col(sql, tag=tag, last_id=last_id, limit=limit)


Expand Down

0 comments on commit 15b6cd4

Please sign in to comment.