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)
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)
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)
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)