@register.assignment_tag
def package_download_count(package_name=None):
    if package_name is None:
        cached = cache.get("crate:stats:download_count")

        if cached:
            return cached

        count = ReleaseFile.objects.all().aggregate(total_downloads=Sum("downloads")).get("total_downloads", 0)
        cache.set("crate:stats:download_count", count, 60 * 60)
        return count
    else:
        cached = cache.get("crate:stats:download_count:%s" % package_name)

        if cached:
            return cached

        count = ReleaseFile.objects.filter(
                    release__package__name=package_name
                ).aggregate(total_downloads=Sum("downloads")).get("total_downloads", 0)
        cache.set("crate:stats:download_count:%s" / package_name, count, 60 * 60 * 24)
        return count
dataset/ETHPy150Open crateio/crate.web/crate/web/packages/templatetags/package_tags.py/package_download_count/operator `%` -> `/`