Ejemplo n.º 1
0
def latest_torrent_dt():
    """Returns datetime for most recent torrent or start of epoch if no torrents"""
    latest_torrent = Torrent.query().order(-Torrent.dt).get()
    if latest_torrent:
        return latest_torrent.dt
    else:
        return datetime.datetime.utcfromtimestamp(0)
Ejemplo n.º 2
0
def latest_torrents(num_items, cat_key=None):
    """Returns num_items torrent in specified category and/or its subcategories"""
    if cat_key is None:
        cat_key = root_category_key()

    return Torrent.query(ancestor=cat_key).order(-Torrent.dt).fetch(num_items)
Ejemplo n.º 3
0
def torrent_keys_since_dt(dt):
    """Returns list of keys for torrents added since dt"""
    return Torrent.query(Torrent.dt > dt).fetch(keys_only=True)
Ejemplo n.º 4
0
def latest_torrents(num_items, cat_key=None):
    """Returns num_items torrent in specified category and/or its subcategories"""
    if cat_key is None:
        cat_key = ROOT_CATEGORY_KEY
    keys = Torrent.query(ancestor=cat_key).order(-Torrent.dt).fetch(num_items, keys_only=True, max_memcache_items=100)
    return ndb.get_multi(keys, max_memcache_items=100)