<commit_before>from . import db
class Sensor(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sensor_key = db.Column(db.String(50), unique=True, nullable=False)
    description = db.Column(db.String(255))

    def __init__(self, sensor_key, description):
        self.sensor_key = sensor_key
        self.description = description

    @property
    def serialise(self):
        return {
            'id': self.id,
            'sensor_key': self.sensor_key,
            'description': self.description
            }

    def __repr__(self):
        return '<Sensor id:{0} key:{1}>'.format(self.id, self.sensor_key)
    <commit_msg>created_at, updated_at and using uuid for internal tracking<commit_after>from uuid import uuid4, UUID
from datetime import datetime
from . import db


class Timestamp(object):
    created_at = db.Column(db.DateTime, default=datetime.utcnow())
    updated_at = db.Column(db.DateTime, default=datetime.utcnow(), onupdate=datetime.utcnow())


class Sensor(db.Model, Timestamp):
    __tablename__ = "sensors"

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50), unique=True, nullable=False)
    redis_key = db.Column(db.String(36), default=str(uuid4()))
    description = db.Column(db.String(255))
    _type = db.Column(db.Integer, db.ForeignKey('type.id'))

    def __init__(self, name, description):
        self.name = name
        self.description = description

    @property
    def uuid(self):
        return UUID(self.redis_key)

    @property
    def serialise(self):
        return {
            'id': self.id,
            'name': self.name,
            'key': str(self.uuid),
            'description': self.description,
            'created_at': str(self.created_at),
            'updated_at': str(self.updated_at)
            }

    def __repr__(self):
        return '<Sensor id:{0} key:{1}>'.format(self.id, self.name)


class Type(db.Model):
    __tablename__ = 'type'

    id = db.Column(db.Integer, primary_key=True)
    _type = db.Column(db.String(), unique=True, nullable=False)

    def __init__(self, _type):
        self._type = _type

    @property
    def serialise(self):
        return {
            'id': self.id,
            'type': self._type
            }

    def __repr__(self):
        return '<Sensor Type id:{0} type:{1}>'.format(self.id, self._type)



{'fraction_non_alphanumeric': 0.13282571912013535, 'fraction_numerical': 0.008460236886632826, 'mean_word_length': 2.6780715396578536, 'pattern_counts': {'":': 0, '<': 6, '<?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': '3186288', 'n_tokens_mistral': 766, 'n_tokens_neox': 749, 'n_words': 155}