示例#1
0
def cached_top_asns(request):
    """See :class:`bgpranking.api.cache_get_top_asns`"""
    cached_dates = bgpranking.cache_get_dates()
    date = request.get('date')
    if date is None or date in cached_dates:
        return json.dumps(bgpranking.cache_get_top_asns(
            request.get('source'), date, request.get('limit'),
            request.get('with_sources')),
            cls=SetEncoder)
    return json.dumps({})
示例#2
0
def cached_position(request):
    """See :class:`bgpranking.api.cache_get_position`"""
    asn = request.get('asn')
    if asn is None:
        return json.dumps({})
    cached_dates = bgpranking.cache_get_dates()
    date = request.get('date')
    if date is None or date in cached_dates:
        return json.dumps(bgpranking.cache_get_position(asn, date=date),
                          cls=SetEncoder)
    return json.dumps({})
示例#3
0
def cached_daily_rank(request):
    """See :class:`bgpranking.api.cache_get_daily_rank`"""
    asn = request.get('asn')
    if asn is None:
        return json.dumps({})
    cached_dates = bgpranking.cache_get_dates()
    date = request.get('date')
    if date is None or date in cached_dates:
        return json.dumps(bgpranking.cache_get_daily_rank(asn,
                          request.get('sources'), date))
    return json.dumps({})
示例#4
0
def cached_dates(request):
    """See :class:`bgpranking.api.cache_get_dates`"""
    return json.dumps(bgpranking.cache_get_dates())