diff --git a/hive/server/bridge_api/cursor.py b/hive/server/bridge_api/cursor.py index 73c0b902..dc2a3ddf 100644 --- a/hive/server/bridge_api/cursor.py +++ b/hive/server/bridge_api/cursor.py @@ -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'" @@ -54,20 +52,12 @@ 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 @@ -75,30 +65,16 @@ async def pids_by_ranked(db, sort, start_author, start_permlink, limit, tag, obs 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) @@ -106,22 +82,14 @@ async def pids_by_ranked(db, sort, start_author, start_permlink, limit, tag, obs # 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) @@ -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) @@ -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)