From ab63bb77b116e01b98f94a99f45cce5176cccb26 Mon Sep 17 00:00:00 2001 From: onlyphantom Date: Fri, 25 Jan 2019 18:07:06 +0700 Subject: [PATCH] fix issue #4 and constraint non-null for workshop fields --- app/analytics.py | 5 ++--- app/models.py | 8 ++++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/analytics.py b/app/analytics.py index b571c94..1fd2309 100644 --- a/app/analytics.py +++ b/app/analytics.py @@ -327,7 +327,7 @@ def global_total_stats(): # 'studenthours': sum(df['workshop_hours'] * df['class_size']), 'companies': sum(df['workshop_category'] == 'Corporate'), 'instructors': len(df['workshop_instructor'].unique()), - 'topten': g.df2.loc[:,['name','workshop_hours', 'class_size']].groupby( + 'topten': g.df2[g.df2.name != 'Capstone'].loc[:,['name','workshop_hours', 'class_size']].groupby( 'name').sum().sort_values( by='workshop_hours', ascending=False).head(10).rename_axis(None).to_html(classes=['table thead-light table-striped table-bordered table-hover table-sm']) @@ -371,8 +371,7 @@ def person_total_stats(): 'fullstar': fullstar, 'responsecount': len(responses), 'qualitative': qualitative, - # change here: - 'topten': g.df2.loc[:,['name','workshop_hours', 'class_size']].groupby( + 'topten': g.df2[g.df2.name != 'Capstone'].loc[:,['name','workshop_hours', 'class_size']].groupby( 'name').sum().sort_values( by='workshop_hours', ascending=False).head(10).rename_axis(None).to_html(classes=['table thead-light table-striped table-bordered table-hover table-sm']) diff --git a/app/models.py b/app/models.py index eb9b466..1d9dcb3 100644 --- a/app/models.py +++ b/app/models.py @@ -39,10 +39,10 @@ class Workshop(db.Model): name="workshop_category"), nullable=False) workshop_instructor = db.Column(db.Integer, db.ForeignKey( 'employee.id'), nullable=False) - workshop_start = db.Column(db.DateTime, default=datetime.utcnow) - workshop_hours = db.Column(db.Integer) - workshop_venue = db.Column(db.String(64)) - class_size = db.Column(db.Integer) + workshop_start = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) + workshop_hours = db.Column(db.Integer, nullable=False) + workshop_venue = db.Column(db.String(64), nullable=False) + class_size = db.Column(db.Integer, nullable=False) responses = db.relationship('Response', backref='workshop', lazy='dynamic') def __repr__(self):