<commit_before># -*- coding: utf-8 -*-
import datetime as dt
from comport.database import (
    Column,
    db,
    Model,
    ReferenceCol,
    relationship,
    SurrogatePK,
)
from comport.charts.models import ChartBlockDefaults

from flask import current_app

from comport.user.models import User, Role

class Department(SurrogatePK, Model):
    __tablename__ = 'departments'
    id = Column(db.Integer, primary_key=True, index=True)
    name = Column(db.String(80), unique=True, nullable=False)
    invite_codes = relationship("Invite_Code", backref="department")
    users = relationship("User", backref="department")
    use_of_force_incidents = relationship("UseOfForceIncident", backref="department")
    chart_blocks = relationship("ChartBlock", backref="department")
    denominator_values = relationship("DenominatorValue", backref="department")

    def get_uof_blocks(self):
        return dict([(block.slug, block) for block in self.blocks if block.dataset == "Use of Force"])

    def get_extractor(self):
        extractors = list(filter(lambda u: u.type == "extractors" ,self.users))
        return extractors[0] if extractors else None

    def __init__(self, name, **kwargs):
        db.Model.__init__(self, name=name, **kwargs)
        for default_chart_block in ChartBlockDefaults.query.all():
            self.chart_blocks.append(default_chart_block.make_real_block())

    def __repr__(self):
        return '<Department({name})>'.format(name=self.name)

    def get_uof_csv(self):
        csv = "id,occuredDate,division,precinct,shift,beat,disposition,censusTract,officerForceType,residentResistType,officerWeaponUsed,residentWeaponUsed,serviceType,arrestMade,arrestCharges,residentInjured,residentHospitalized,officerInjured,officerHospitalized,useOfForceReason,residentRace,officerRace,officerYearsOfService,officerIdentifier\n"
        use_of_force_incidents = self.use_of_force_incidents
        for incident in use_of_force_incidents:
            csv += incident.to_csv_row()
        return csv

    def get_denominator_csv(self):
        csv = "month,year,arrests,callsForService,officerInitiatedCalls\n"
        denominator_values = self.denominator_values
        for month in denominator_values:
            csv += month.to_csv_row()
        return csv
<commit_msg>rename blocks_field<commit_after># -*- coding: utf-8 -*-
import datetime as dt
from comport.database import (
    Column,
    db,
    Model,
    ReferenceCol,
    relationship,
    SurrogatePK,
)
from comport.charts.models import ChartBlockDefaults

from flask import current_app

from comport.user.models import User, Role

class Department(SurrogatePK, Model):
    __tablename__ = 'departments'
    id = Column(db.Integer, primary_key=True, index=True)
    name = Column(db.String(80), unique=True, nullable=False)
    invite_codes = relationship("Invite_Code", backref="department")
    users = relationship("User", backref="department")
    use_of_force_incidents = relationship("UseOfForceIncident", backref="department")
    chart_blocks = relationship("ChartBlock", backref="department")
    denominator_values = relationship("DenominatorValue", backref="department")

    def get_uof_blocks(self):
        return dict([(block.slug, block) for block in self.chart_blocks if block.dataset == "Use of Force"])

    def get_extractor(self):
        extractors = list(filter(lambda u: u.type == "extractors" ,self.users))
        return extractors[0] if extractors else None

    def __init__(self, name, **kwargs):
        db.Model.__init__(self, name=name, **kwargs)
        for default_chart_block in ChartBlockDefaults.query.all():
            self.chart_blocks.append(default_chart_block.make_real_block())

    def __repr__(self):
        return '<Department({name})>'.format(name=self.name)

    def get_uof_csv(self):
        csv = "id,occuredDate,division,precinct,shift,beat,disposition,censusTract,officerForceType,residentResistType,officerWeaponUsed,residentWeaponUsed,serviceType,arrestMade,arrestCharges,residentInjured,residentHospitalized,officerInjured,officerHospitalized,useOfForceReason,residentRace,officerRace,officerYearsOfService,officerIdentifier\n"
        use_of_force_incidents = self.use_of_force_incidents
        for incident in use_of_force_incidents:
            csv += incident.to_csv_row()
        return csv

    def get_denominator_csv(self):
        csv = "month,year,arrests,callsForService,officerInitiatedCalls\n"
        denominator_values = self.denominator_values
        for month in denominator_values:
            csv += month.to_csv_row()
        return csv

{'fraction_non_alphanumeric': 0.10069444444444445, 'fraction_numerical': 0.001736111111111111, 'mean_word_length': 4.4869047619047615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1754473', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1378, 'n_words': 259}