class TrainingWeek(db.Model): __tablename__ = "training_week" id = db.Column(db.Integer, primary_key=True) start_date = db.Column(db.Date, nullable=False) athlete_id = db.Column(db.Integer, db.ForeignKey("athlete.id"), nullable=False)
class Athlete(db.Model): __tablename__ = "athlete" id = db.Column(db.Integer, primary_key=True) age = db.Column(db.Integer, nullable=False) gender = db.Column(db.String, nullable=False) weight = db.Column(db.Float, nullable=False) vdot_value = db.Column(db.Integer, nullable=True)
class VdotTempo(db.Model): __tablename__ = "vdot_tempo_values" id = db.Column(db.Integer, primary_key=True) tempo = db.Column(db.Integer, db.ForeignKey("tempo.id"), nullable=False) vdot = db.Column(db.Float, nullable=False) pace_in_seconds_per_km = db.Column(db.Integer, nullable=False) distance_in_meter = db.Column(db.Integer, nullable=True)
class PersonalBest(db.Model): __tablename__ = "personal_best" id = db.Column(db.Integer, primary_key=True) distance_in_meter = db.Column(db.Integer, nullable=False) time_in_seconds = db.Column(db.Integer, nullable=False) athlete_id = db.Column(db.Integer, db.ForeignKey("athlete.id"), nullable=False) athlete = db.relationship("Athlete", backref="personalbest")
class TrainingWeekSchedule(db.Model): __tablename__ = "training_week_schedule" id = db.Column(db.Integer, primary_key=True) training_week_id = db.Column(db.Integer, db.ForeignKey("training_week.id"), nullable=False) training_id = db.Column(db.Integer, db.ForeignKey("training.id"), nullable=False)
class Training(db.Model): """ Intensity of training can be derived from the VDOT values of the tempo. sum(tempo.vdot_percent) """ __tablename__ = "training" id = db.Column(db.Integer, primary_key=True) training_type_id = db.Column(db.Integer, db.ForeignKey("training_type.id"), nullable=False)
class Tempo(db.Model): __tablename__ = "tempo" id = db.Column(db.Integer, primary_key=True) lower_percentage_hr = db.Column(db.Float, nullable=False) upper_percentage_hr = db.Column(db.Float, nullable=False) lower_percentage_max_vdot = db.Column(db.Float, nullable=False) upper_percentage_max_vdot = db.Column(db.Float, nullable=False) name = db.Column(db.String, nullable=False) description = db.Column(db.String, nullable=True)
class BaseModel(db.Model): __abstract__ = True created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False) updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False) deleted_at = db.Column(db.DateTime, nullable=False, index=True) def save(self, flush=False): db.session.add(self) db.session.commit() if flush: db.session.refresh(self) db.session.flush() return self def datetime(self): db.session.delete(self) db.session.commit()
class TrainingLap(db.Model): # TODO: PK should be composite of training_id, lap __tablename__ = "training_lap" id = db.Column(db.Integer, primary_key=True) training_id = db.Column(db.Integer, db.ForeignKey("training.id"), nullable=False) lap = db.Column(db.Integer, nullable=False) tempo = db.Column(db.Integer, db.ForeignKey("tempo.id"), nullable=False) distance_in_meter = db.Column(db.Integer, nullable=True) time_in_seconds = db.Column(db.Integer, nullable=True) training = db.relationship("Training", backref="traininglap")
class Book(BaseModel): __tablename__ = 'book' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(200), nullable=True) author_id = db.Column(db.Integer, db.ForeignKey('author.id'))
class Author(BaseModel): __tablename__ = 'author' id = db.Column(db.Integer, primary_key=True, autoincrement=True) name = db.Column(db.String(200), nullable=False)
class TrainingType(db.Model): __tablename__ = "training_type" id = db.Column(db.Integer, primary_key=True) type_name = db.Column(db.String, nullable=False)
class Vdot(db.Model): __tablename__ = "vdot_values" id = db.Column(db.Integer, primary_key=True) vdot = db.Column(db.Float, nullable=False) distance_in_meter = db.Column(db.Integer, nullable=False) time_in_seconds = db.Column(db.Integer, nullable=False)