<commit_before>from uber.common import *


def prereg_money(session):
    preregs = defaultdict(int)
    for attendee in session.query(Attendee):
        preregs['Attendee'] += attendee.amount_paid - attendee.amount_extra
        preregs['extra'] += attendee.amount_extra

    preregs['group_badges'] = sum(g.badge_cost for g in session.query(Group)
                                                               .filter(Group.tables == 0, Group.amount_paid > 0)
                                                               .options(joinedload(Group.attendees)))

    dealers = session.query(Group).filter(Group.tables > 0, Group.amount_paid > 0).options(joinedload(Group.attendees)).all()
    preregs['dealer_tables'] = sum(d.table_cost for d in dealers)
    preregs['dealer_badges'] = sum(d.badge_cost for d in dealers)

    return preregs


def sale_money(session):
    sales = defaultdict(int)
    for sale in session.query(Sale).all():
        sales[sale.what] += sale.cash
    return dict(sales)  # converted to a dict so we can say sales.items in our template


@all_renderable(c.MONEY)
class Root:
    @log_pageview
    def index(self, session):
        sales   = sale_money(session)
        preregs = prereg_money(session)
        total = sum(preregs.values()) + sum(sales.values())
        return {
            'total':   total,
            'preregs': preregs,
            'sales':   sales
        }

    @log_pageview
    def mpoints(self, session):
        groups = defaultdict(list)
        for mpu in session.query(MPointsForCash).options(joinedload(MPointsForCash.attendee).subqueryload(Attendee.group)):
            groups[mpu.attendee and mpu.attendee.group].append(mpu)
        all = [(sum(mpu.amount for mpu in mpus), group, mpus)
               for group, mpus in groups.items()]
        return {'all': sorted(all, reverse=True)}

    @csv_file
    def kickins(self, out, session):
        totals = defaultdict(int)
        for attendee in session.query(Attendee):
            totals['Extra'] += attendee.amount_extra
            for x in attendee.donation_swag:
                totals[x] += 1
        for x in sorted(totals):<commit_msg>filter by completed badges only<commit_after>from uber.common import *


def prereg_money(session):
    preregs = defaultdict(int)
    for attendee in session.query(Attendee):
        preregs['Attendee'] += attendee.amount_paid - attendee.amount_extra
        preregs['extra'] += attendee.amount_extra

    preregs['group_badges'] = sum(g.badge_cost for g in session.query(Group)
                                                               .filter(Group.tables == 0, Group.amount_paid > 0)
                                                               .options(joinedload(Group.attendees)))

    dealers = session.query(Group).filter(Group.tables > 0, Group.amount_paid > 0).options(joinedload(Group.attendees)).all()
    preregs['dealer_tables'] = sum(d.table_cost for d in dealers)
    preregs['dealer_badges'] = sum(d.badge_cost for d in dealers)

    return preregs


def sale_money(session):
    sales = defaultdict(int)
    for sale in session.query(Sale).all():
        sales[sale.what] += sale.cash
    return dict(sales)  # converted to a dict so we can say sales.items in our template


@all_renderable(c.MONEY)
class Root:
    @log_pageview
    def index(self, session):
        sales   = sale_money(session)
        preregs = prereg_money(session)
        total = sum(preregs.values()) + sum(sales.values())
        return {
            'total':   total,
            'preregs': preregs,
            'sales':   sales
        }

    @log_pageview
    def mpoints(self, session):
        groups = defaultdict(list)
        for mpu in session.query(MPointsForCash).options(joinedload(MPointsForCash.attendee).subqueryload(Attendee.group)):
            groups[mpu.attendee and mpu.attendee.group].append(mpu)
        all = [(sum(mpu.amount for mpu in mpus), group, mpus)
               for group, mpus in groups.items()]
        return {'all': sorted(all, reverse=True)}

    @csv_file
    def kickins(self, out, session):
        totals = defaultdict(int)
        for attendee in session.query(Attendee).filter(Attendee.badge_status==c.COMPLETED_STATUS):
            totals['Extra'] += attendee.amount_extra
            for x in attendee.donation_swag:
                totals[x] += 1
        for x in sorted(totals):
{'fraction_non_alphanumeric': 0.1109845031905196, 'fraction_numerical': 0.0022789425706472195, 'mean_word_length': 2.3813559322033897, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3369777', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1321, 'n_words': 291}