Example #1
0
class Champions(db.Model):
    PKEY_NAME = "champions_year_pkey"

    year = db.Column(db.Integer, nullable=False)
    owner_id = db.Column(db.String, nullable=False)
    db.PrimaryKeyConstraint(year, name=PKEY_NAME)

    def __str__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items()
                         if "_json" not in item)

    def __repr__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items()
                         if "_json" not in item)

    def __key(self):
        return (self.year, self.owner_id)

    def __hash__(self):
        return hash(self.__key())

    def __eq__(self, other):
        return isinstance(self, type(other)) and self.__key() == other.__key()

    def as_dict(self):
        return {'year': self.year, 'owner_id': self.owner_id}

    def props_dict(self):
        return self.as_dict()
Example #2
0
class Owners(db.Model):
    PKEY_NAME = "owners_username_pkey"

    id = db.Column(db.String, nullable=False)
    username = db.Column(db.String, nullable=False)
    first_name = db.Column(db.String, nullable=False)
    last_name = db.Column(db.String, nullable=False)
    db.PrimaryKeyConstraint(username, name=PKEY_NAME)

    def __key(self):
        return (
            self.id,
            self.username,
            self.first_name,
            self.last_name
        )

    def __hash__(self):
        return hash(self.__key())

    def __eq__(self, other):
        return isinstance(self, type(other)) and self.__key() == other.__key()

    def as_dict(self):
        return {
            'id': self.id,
            'username': self.username,
            'first_name': self.first_name,
            'last_name': self.last_name
        }

    def props_dict(self):
        return self.as_dict()
Example #3
0
class Records(db.Model):
    PKEY_NAME = "records_year_team_id_pkey"

    year = db.Column(db.Integer, nullable=False)
    team_id = db.Column(db.Integer, nullable=False)
    owner_id = db.Column(db.String, nullable=False)
    standing = db.Column(db.Integer, nullable=False)
    wins = db.Column(db.Integer, nullable=False)
    losses = db.Column(db.Integer, nullable=False)
    ties = db.Column(db.Integer, nullable=False)
    points_for = db.Column(db.Numeric, nullable=False)
    points_against = db.Column(db.Numeric, nullable=False)
    streak_length = db.Column(db.Integer, nullable=False)
    streak_type = db.Column(db.String, nullable=False)
    db.PrimaryKeyConstraint(year, team_id, name=PKEY_NAME)

    def __str__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items() if "_json" not in item)

    def __repr__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items() if "_json" not in item)

    def __key(self):
        return (
            self.year,
            self.team_id,
            self.owner_id,
            self.standing,
            self.wins,
            self.losses,
            self.ties,
            self.points_for,
            self.points_against,
            self.streak_length,
            self.streak_type
        )

    def __hash__(self):
        return hash(self.__key())

    def __eq__(self, other):
        return isinstance(self, type(other)) and self.__key() == other.__key()

    def as_dict(self):
        return {
            'year': self.year,
            'team_id': self.team_id,
            'owner_id': self.owner_id,
            'standing': self.standing,
            'wins': self.wins,
            'losses': self.losses,
            'ties': self.ties,
            'points_for': self.points_for,
            'points_against': self.points_against,
            'streak_length': self.streak_length,
            'streak_type': self.streak_type
        }

    def props_dict(self):
        return self.as_dict()
Example #4
0
class Matchups(db.Model):
    PKEY_NAME = "matchups_year_matchup_id_team_id_pkey"

    year = db.Column(db.Integer, nullable=False)
    matchup_id = db.Column(db.Integer, nullable=False)
    team_id = db.Column(db.Integer, nullable=False)
    owner_id = db.Column(db.String, nullable=False)
    opponent_team_id = db.Column(db.Integer)
    opponent_owner_id = db.Column(db.String)
    team_score = db.Column(db.Numeric, nullable=False)
    opponent_team_score = db.Column(db.Numeric)
    is_win = db.Column(db.Boolean, nullable=False)
    is_loss = db.Column(db.Boolean, nullable=False)
    is_pending = db.Column(db.Boolean, nullable=False)
    is_bye = db.Column(db.Boolean, nullable=False)
    is_playoffs = db.Column(db.Boolean, nullable=False)
    is_consolation = db.Column(db.Boolean, nullable=False)
    db.PrimaryKeyConstraint(year, matchup_id, team_id, name=PKEY_NAME)

    def __str__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items()
                         if "_json" not in item)

    def __repr__(self):
        return ', '.join("%s: %s" % item for item in vars(self).items()
                         if "_json" not in item)

    def __key(self):
        return (self.year, self.matchup_id, self.team_id, self.owner_id,
                self.opponent_team_id, self.opponent_owner_id, self.team_score,
                self.opponent_team_score, self.is_win, self.is_loss,
                self.is_pending, self.is_bye, self.is_playoffs,
                self.is_consolation)

    def __hash__(self):
        return hash(self.__key())

    def __eq__(self, other):
        return isinstance(self, type(other)) and self.__key() == other.__key()

    def as_dict(self):
        return {
            'year': self.year,
            'matchup_id': self.matchup_id,
            'team_id': self.team_id,
            'owner_id': self.owner_id,
            'opponent_team_id': self.opponent_team_id,
            'opponent_owner_id': self.opponent_owner_id,
            'team_score': self.team_score,
            'opponent_team_score': self.opponent_team_score,
            'is_win': self.is_win,
            'is_loss': self.is_loss,
            'is_pending': self.is_pending,
            'is_bye': self.is_bye,
            'is_playoffs': self.is_playoffs,
            'is_consolation': self.is_consolation
        }

    def props_dict(self):
        return self.as_dict()