<commit_before>from subscription.models import UserSubscription

from .models import RawImage

def user_used_bytes(user):
    sizes = RawImage.objects\
        .filter(user = user)\
        .values_list('size', flat = True)
    return sum(sizes)


def user_used_percent(user):
    b = user_used_bytes(user)
    limit = user_byte_limit(user)
    return b * 100 / limit


def user_progress_class(user):
    p = user_used_percent(user)
    if p < 90: return 'progress-success'
    if p > 97: return 'progress-danger'<commit_msg>(rawdata) Fixes potential division by 0.<commit_after>from subscription.models import UserSubscription

from .models import RawImage

def user_used_bytes(user):
    sizes = RawImage.objects\
        .filter(user = user)\
        .values_list('size', flat = True)
    return sum(sizes)


def user_used_percent(user):
    b = user_used_bytes(user)
    limit = user_byte_limit(user)
    return b * 100 / limit if limit > 0 else 100


def user_progress_class(user):
    p = user_used_percent(user)
    if p < 90: return 'progress-success'
    if p > 97: return 'progress-danger'
{'fraction_non_alphanumeric': 0.09827115559599636, 'fraction_numerical': 0.017288444040036398, 'mean_word_length': 3.489795918367347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2080187', 'n_tokens_mistral': 370, 'n_tokens_neox': 348, 'n_words': 95}