<commit_before>from influxdb_metrics.loader import write_points

from foodsaving.groups.stats import group_tags


def pickup_tags(pickup):
    tags = group_tags(pickup.store.group)
    tags.update({
        'store': str(pickup.store.id),
    })
    return tags


def pickup_joined(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_joined': 1
        },
    }])


def pickup_left(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_left': 1
        },
    }])


def pickup_done(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_done': 1
        },
    }])


def pickup_missed(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_missed': 1
        },
    }])


def pickup_disabled(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {<commit_msg>add stats about slots filled on done pickups<commit_after>from influxdb_metrics.loader import write_points

from foodsaving.groups.stats import group_tags


def pickup_tags(pickup):
    tags = group_tags(pickup.store.group)
    tags.update({
        'store': str(pickup.store.id),
    })
    return tags


def pickup_joined(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_joined': 1
        },
    }])


def pickup_left(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_left': 1
        },
    }])


def pickup_done(pickup):
    collectors_count = pickup.collectors.count()
    fields = {
        'pickup_done': 1,
        'pickup_done_slots_joined': collectors_count,
    }

    if pickup.max_collectors is not None:
        fields.update({
            'pickup_done_slots_total': pickup.max_collectors,
            'pickup_done_slots_percentage': collectors_count / pickup.max_collectors,
        })

    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': fields,
    }])


def pickup_missed(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
            'pickup_missed': 1
        },
    }])


def pickup_disabled(pickup):
    write_points([{
        'measurement': 'karrot.events',
        'tags': pickup_tags(pickup),
        'fields': {
{'fraction_non_alphanumeric': 0.13629790310918294, 'fraction_numerical': 0.0028922631959508315, 'mean_word_length': 2.374390243902439, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6583444', 'n_tokens_mistral': 941, 'n_tokens_neox': 900, 'n_words': 154}