class CategoryStage(Base): name = db.Column(db.String(250)) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) category = db.relationship('Category', backref=db.backref('category', lazy='dynamic')) results = relationship("Result") def __init__(self, name, category_id): self.name = name self.category_id = category_id
class EventStage(Base): name = db.Column(db.String(250)) event_id = db.Column(db.Integer, db.ForeignKey('event.id')) event = db.relationship('Event', backref=db.backref('event_stage_event', lazy='dynamic')) results = relationship("Result") def __init__(self, name, event_id): self.name = name self.event_id = event_id
class SASEvent(Base): event_reference = db.Column(db.String(250), unique=True) event_id = db.Column(db.Integer, db.ForeignKey('event.id')) event = db.relationship('Event', backref=db.backref('sas_to_event', lazy='dynamic')) def __init__(self, event_id, event_reference): self.event_id = event_id self.event_reference = event_reference
class Category(Base): name = db.Column(db.String(250), nullable=False) event_id = db.Column(db.Integer, db.ForeignKey('event.id')) event = db.relationship('Event', backref=db.backref('event', lazy='dynamic')) category_stages = relationship("CategoryStage") results = relationship("Result") def __init__(self,name, event_id): self.name = name self.event_id = event_id
class RTEventStage(Base): stage_reference = db.Column(db.String(250), unique=True) event_stage_id = db.Column(db.Integer, db.ForeignKey('event_stage.id')) event_stage = db.relationship('EventStage', backref=db.backref('rt_event_stage', lazy='dynamic')) def __init__(self, event_stage_id, stage_reference): self.event_stage_id = event_stage_id self.stage_reference = stage_reference
class RTCategory(Base): category_reference = db.Column(db.String(250), unique=True) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) category = db.relationship('Category', backref=db.backref('rt_to_category', lazy='dynamic')) def __init__(self, category_reference, category_id): self.category_reference = category_reference self.category_id = category_id
class SASCategoryStage(Base): stage_reference = db.Column(db.String(250), unique=True) category_stage_id = db.Column(db.Integer, db.ForeignKey('category_stage.id')) category_stage = db.relationship('CategoryStage', backref=db.backref('category_stage', lazy='dynamic')) def __init__(self, category_stage_id, stage_reference): self.category_stage_id = category_stage_id self.stage_reference = stage_reference
class Result(Base): position = db.Column(db.Integer) participant_id = db.Column(db.Integer, db.ForeignKey('participant.id')) participant = db.relationship('Participant', backref=db.backref('result_category', lazy='dynamic')) gender_position = db.Column(db.Integer) time = db.Column(db.Integer) event_stage_id = db.Column(db.Integer, db.ForeignKey('event_stage.id')) event_stage = db.relationship('EventStage', backref=db.backref('result_event_stage', lazy='dynamic')) category_stage_id = db.Column(db.Integer, db.ForeignKey('category_stage.id')) category_stage = db.relationship('CategoryStage', backref=db.backref('result_category_stage', lazy='dynamic')) category_id = db.Column(db.Integer, db.ForeignKey('category.id')) category = db.relationship('Category', backref=db.backref('result_category', lazy='dynamic')) def __init__(self, position, participant_id, gender_position, time, event_stage_id, category_stage_id, category_id): self.position = position self.participant_id = participant_id self.gender_position = gender_position self.time = time self.event_stage_id = event_stage_id self.category_stage_id = category_stage_id self.category_id = category_id
class TrackData(db.Model): cyclone_id = db.Column(db.String(20), db.ForeignKey(CycloneInfo.cyclone_id), primary_key=True, nullable=False) synoptic_time = db.Column(db.BigInteger, nullable=False, primary_key=True) latitude = db.Column(db.Float, default=0, nullable=False) longitude = db.Column(db.Float, default=0, nullable=False) intensity = db.Column(db.Integer, default=0, nullable=False) def __repr__(self): return '<TrackData %r>' % self.cyclone_id def toJSON(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class ForecastData(db.Model): cyclone_id = db.Column(db.String(20), db.ForeignKey(CycloneInfo.cyclone_id), nullable=False, primary_key=True) forecast_time = db.Column(db.BigInteger, nullable=False, primary_key=True) predicted_time = db.Column(db.BigInteger, nullable=False, primary_key=True) latitude = db.Column(db.Float, default=0, nullable=False) longitude = db.Column(db.Float, default=0, nullable=False) intensity = db.Column(db.Integer, default=0, nullable=False) def __repr__(self): return '<ForecastData %r>' % self.cyclone_id def toJSON(self): return { attr.name: getattr(self, attr.name) for attr in self.__table__.columns }