<commit_before># Copyright 2017 <NAME>
# Copyright 2017 <NAME>
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import config
import peewee
from peewee import *

(scheme, url) = config.DATABASE_URL.split('://')
db = {
    'mysql': peewee.MySQLDatabase,
    'postgres': peewee.PostgresqlDatabase,
    'sqlite': peewee.SqliteDatabase,
}[scheme](url)

class BaseModel(Model):
    class Meta:
        database = db


class Term(BaseModel):
    """
    Term is the numerical representation of year and semester by Memorial University
    """
    year = IntegerField()
    session = IntegerField()


class Person(BaseModel):
    """
    A person in this database is a teaching professional
    """
    name = TextField(null=False)
    email = TextField(unique=True)
    start = ForeignKeyField(Term, related_name='startdate', null=False)
    retired = BooleanField(null=True)
    reviewed = BooleanField(default=False)
    # def load(self):


class Deficit(BaseModel):
    """
    To track the irregular deficits accumulated by professors
    """
    deficit = FloatField(null=True)
    applied = ForeignKeyField(Person, related_name='applicant', null=False)
    applied_start = IntegerField(null=True)
    applied_final = IntegerField(null=True)


class Course(BaseModel):
    """
    A person in this database is a teaching professional
    """
    subject = TextField()
    # Because of courses like 200W we cannot store info as int
    code = CharField(4)
    reviewed = BooleanField(default=False)


class CourseGeneration(BaseModel):
    """
    As a course changes over time it becomes necessary to update it to moder information
    """
    # due to situations like 4.5 these numbers are stored as doubles
    labs = DoubleField(null=True)
    credit_hours = DoubleField(null=True)
    lecture_hours = DoubleField(null=True)
    title = TextField(null=True)
    comments = TextField(null=True)
    course = ForeignKeyField(Course, related_name='generation', null=True)
    other_info = TextField(null=True)
    previous_course = TextField(null=True)
    start_year = TextField(null=False)
    end_year = TextField(null=False)
    reviewed = BooleanField(default=False)


class Student(BaseModel):
    """
    A student is typically a non-undergrad student
    """
    name = TextField()
    email = TextField()


class Offering(BaseModel):
    """
    Display the current courses on offering during the current session
    """
    enrolment = IntegerField()
    # prof_id = ForeignKeyField(Person, related_name='instructor')
    semester = ForeignKeyField(Term, related_name='semester')
    generation = ForeignKeyField(CourseGeneration, related_name='generation')
    sections = IntegerField(null=True)
    reviewed = BooleanField(default=False)


class Role(BaseModel):
    """
    These fields represent the class of the user and information they have access too, dept is short for department.
    """
    role_name = TextField(null=False)
    view_you = BooleanField(null=False)<commit_msg>Add some __str__ methods to database classes.<commit_after># Copyright 2017 <NAME>
# Copyright 2017 <NAME>
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.

import config
import peewee
from peewee import *

(scheme, url) = config.DATABASE_URL.split('://')
db = {
    'mysql': peewee.MySQLDatabase,
    'postgres': peewee.PostgresqlDatabase,
    'sqlite': peewee.SqliteDatabase,
}[scheme](url)

class BaseModel(Model):
    class Meta:
        database = db


class Term(BaseModel):
    """
    Term is the numerical representation of year and semester by Memorial University
    """
    year = IntegerField()
    session = IntegerField()


class Person(BaseModel):
    """
    A person in this database is a teaching professional
    """
    name = TextField(null=False)
    email = TextField(unique=True)
    start = ForeignKeyField(Term, related_name='startdate', null=False)
    retired = BooleanField(null=True)
    reviewed = BooleanField(default=False)
    # def load(self):


class Deficit(BaseModel):
    """
    To track the irregular deficits accumulated by professors
    """
    deficit = FloatField(null=True)
    applied = ForeignKeyField(Person, related_name='applicant', null=False)
    applied_start = IntegerField(null=True)
    applied_final = IntegerField(null=True)


class Course(BaseModel):
    """
    A person in this database is a teaching professional
    """
    subject = TextField()
    # Because of courses like 200W we cannot store info as int
    code = CharField(4)
    reviewed = BooleanField(default=False)

    def __str__(self):
        return '%s %s' % (self.subject, self.code)


class CourseGeneration(BaseModel):
    """
    As a course changes over time it becomes necessary to update it to moder information
    """
    # due to situations like 4.5 these numbers are stored as doubles
    labs = DoubleField(null=True)
    credit_hours = DoubleField(null=True)
    lecture_hours = DoubleField(null=True)
    title = TextField(null=True)
    comments = TextField(null=True)
    course = ForeignKeyField(Course, related_name='generation', null=True)
    other_info = TextField(null=True)
    previous_course = TextField(null=True)
    start_year = TextField(null=False)
    end_year = TextField(null=False)
    reviewed = BooleanField(default=False)

    def __str__(self):
        return '%s (%d-%d)' % (self.course, self.start_year, self.end_year)


class Student(BaseModel):
    """
    A student is typically a non-undergrad student
    """
    name = TextField()
    email = TextField()

    def __str__(self):
        return '%s (%s)' % (name, email)


class Offering(BaseModel):
    """
    Display the current courses on offering during the current session
    """
    enrolment = IntegerField()
    # prof_id = ForeignKeyField(Person, related_name='instructor')
    semester = ForeignKeyField(Term, related_name='semester')
    generation = ForeignKeyField(CourseGeneration, related_name='generation')
    sections = IntegerField(null=True)
    reviewed = BooleanField(default=False)


class Role(BaseModel):
    """
    These fields represent the class of the user and information they have access too, dept is short for department.
    """
    role_name = TextField(null=False)
    view_you = BooleanField(null=False)
{'fraction_non_alphanumeric': 0.09543341536778781, 'fraction_numerical': 0.004922067268252666, 'mean_word_length': 3.7376943005181347, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2899751', 'n_tokens_mistral': 2108, 'n_tokens_neox': 2043, 'n_words': 663}