<commit_before>import os.path
from datetime import datetime
from flask import json
from flaskext.sqlalchemy import SQLAlchemy
import logging

log = logging.getLogger(__name__)
log.setLevel(logging.INFO)

db = SQLAlchemy()


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    openid_url = db.Column(db.Text())
    name = db.Column(db.Text())
    email = db.Column(db.Text())


class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text())


class Property(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    person_id = db.Column(db.Integer, db.ForeignKey('person.id'))
    person = db.relationship('Person',
        backref=db.backref('properties', lazy='dynamic'))
    name = db.Column(db.String(30))
    value = db.Column(db.Text())


class Suggestion(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship('User', primaryjoin=(user_id==User.id),
        backref=db.backref('suggestions', lazy='dynamic'))
    person_id = db.Column(db.Integer, db.ForeignKey('person.id'))
    person = db.relationship('Person',
        backref=db.backref('suggestions', lazy='dynamic'))
    name = db.Column(db.String(30))
    value = db.Column(db.Text())
    date = db.Column(db.DateTime(timezone=True))
    admin_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    admin = db.relationship('User', primaryjoin=(admin_id==User.id),
        backref=db.backref('decisions', lazy='dynamic'))
    decision = db.Column(db.String(10))


def get_persons():
    results = {}

    for person in Person.query.all():
        results[person.id] = person_data = {'name': person.name}

        for prop in person.properties.all():
            person_data[prop.name] = prop.value

    return results


def import_fixture(flush=True):
    data_path = os.path.join(os.path.dirname(__file__), 'data')
    fixture_path = os.path.join(data_path, 'fixture.json')

    if flush:
        db.drop_all()
        db.create_all()

    with open(fixture_path, 'rb') as f:
        fixture = json.load(f)

    for person_data in fixture:

        person = Person(id=person_data.pop('id'), name=person_data.pop('name'))<commit_msg>remove the Suggestion model<commit_after>import os.path
from datetime import datetime
from flask import json
from flaskext.sqlalchemy import SQLAlchemy
import logging

log = logging.getLogger(__name__)
log.setLevel(logging.INFO)

db = SQLAlchemy()


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    openid_url = db.Column(db.Text())
    name = db.Column(db.Text())
    email = db.Column(db.Text())


class Person(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.Text())


class Property(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    person_id = db.Column(db.Integer, db.ForeignKey('person.id'))
    person = db.relationship('Person',
        backref=db.backref('properties', lazy='dynamic'))
    name = db.Column(db.String(30))
    value = db.Column(db.Text())


def get_persons():
    results = {}

    for person in Person.query.all():
        results[person.id] = person_data = {'name': person.name}

        for prop in person.properties.all():
            person_data[prop.name] = prop.value

    return results


def import_fixture(flush=True):
    data_path = os.path.join(os.path.dirname(__file__), 'data')
    fixture_path = os.path.join(data_path, 'fixture.json')

    if flush:
        db.drop_all()
        db.create_all()

    with open(fixture_path, 'rb') as f:
        fixture = json.load(f)

    for person_data in fixture:

        person = Person(id=person_data.pop('id'), name=person_data.pop('name'))
{'fraction_non_alphanumeric': 0.14965443912812335, 'fraction_numerical': 0.002126528442317916, 'mean_word_length': 3.566747572815534, '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': '1112009', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1243, 'n_words': 238}