def get_transaction_cursor_near_timestamp(namespace_id, timestamp, db_session):
 dt = datetime.utcfromtimestamp(timestamp)
 latest_timestamp = db_session.query(Transaction.created_at).order_by(desc(Transaction.created_at)).filter((Transaction.created_at < dt), (Transaction.namespace_id == namespace_id)).limit(1).subquery()
 latest_transaction = db_session.query(Transaction).filter((Transaction.created_at == latest_timestamp), (Transaction.namespace_id == namespace_id)).order_by(desc(Transaction.id)).first()
 if (latest_transaction is None):
  return '0'
 return latest_transaction.public_id

def get_transaction_cursor_near_timestamp ( namespace_id , timestamp , db_session ) : dt = datetime . utcfromtimestamp ( timestamp ) latest_timestamp = db_session . query ( Transaction . created_at ) . order_by ( desc ( Transaction . created_at ) ) . filter ( ( Transaction . created_at < dt ) , ( Transaction . namespace_id == namespace_id ) ) . limit ( 1 ) . subquery ( ) latest_transaction = db_session . query ( Transaction ) . filter ( ( Transaction . created_at == latest_timestamp ) , ( Transaction . namespace_id == namespace_id ) ) . order_by ( desc ( Transaction . id ) ) . first ( ) if ( latest_transaction is None ) : return '0' return latest_transaction . public_id
exchange a timestamp for a cursor into the transaction log entry near to that timestamp in age .