class CoasterGoal(db.Model): __tablename__ = 'coastergoals' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(500), unique=False) description = db.Column(db.String(1000), unique=False) progress = db.Column(db.Integer) notes = db.relationship('CoasterGoalNote') # 1 = ongoing, 2 = abandoned, 3 = completed status = db.Column(db.Integer) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class Job(db.Model): __tablename__ = 'jobs' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) pythonFile = db.Column(db.String(53)) description = db.Column(db.String(1000)) cronString = db.Column(db.String(50)) active = db.Column(db.Boolean) lastRun = db.Column(db.DateTime) options = db.Column(db.String(1000)) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class CoasterWaitTime(db.Model): __tablename__ = 'coasterwaittimes' id = db.Column(db.Integer, primary_key=True) park = db.Column(db.Integer, ForeignKey('coasterparks.id')) ride = db.Column(db.Integer, ForeignKey('coasterrides.id')) waitTime = db.Column(db.Integer) weather = db.Column(db.String(40)) temp = db.Column(db.Integer) humidity = db.Column(db.Integer) windspeed = db.Column(db.Integer) datetime = db.Column(db.DateTime) earlyEntry = db.Column(db.Boolean) def as_dict(self): waitTime = {} waitTime["id"] = self.id waitTime["park"] = self.park waitTime["ride"] = self.ride waitTime["waitTime"] = self.waitTime waitTime["weather"] = self.weather waitTime["temp"] = self.temp waitTime["humidity"] = self.humidity waitTime["windspeed"] = self.windspeed waitTime["datetime"] = self.datetime.isoformat() waitTime["earlyEntry"] = self.earlyEntry return waitTime
class CoasterRide(db.Model): __tablename__ = 'coasterrides' id = db.Column(db.Integer, primary_key=True) park = db.Column(db.Integer, ForeignKey('coasterparks.id')) waitTimes = db.relationship('CoasterWaitTime') tracks = db.relationship('CoasterTrack') name = db.Column(db.String(500), unique=False) description = db.Column(db.String(1000), unique=False) rcdbID = db.Column(db.Integer) wikipediaLink = db.Column(db.String(500), unique=False) ridden = db.Column(db.Boolean, default=False) coasterOrRide = db.Column(db.Boolean) status = db.Column(db.Integer) statusDate = db.Column(db.String(40), unique=False) openDate = db.Column(db.String(40), unique=False) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class CoasterGoalNote(db.Model): __tablename__ = 'coastergoalnotes' id = db.Column(db.Integer, primary_key=True) goal = db.Column(db.Integer, db.ForeignKey('coastergoals.id')) contents = db.Column(db.String(2000), unique=False) created = db.Column(db.DateTime, default=datetime.datetime.utcnow) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class CoasterJournalEntry(db.Model): __tablename__ = 'journalentries' id = db.Column(db.Integer, primary_key=True) title = db.Column(db.String(500), unique=False) content = db.Column(db.Text) datetime = db.Column(db.DateTime) park = db.Column(db.Integer, db.ForeignKey('coasterparks.id')) def as_dict(self): journal = {} journal["id"] = self.id journal["title"] = self.title journal["content"] = self.content journal["datetime"] = self.datetime.isoformat() journal["park"] = CoasterPark.query.get(self.park).as_dict() return journal
class CoasterPark(db.Model): __tablename__ = 'coasterparks' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(500), unique=False) description = db.Column(db.String(1000), unique=False) rcdbID = db.Column(db.Integer) wikipediaLink = db.Column(db.String(500), unique=False) rides = db.relationship('CoasterRide') waitTimes = db.relationship('CoasterWaitTime') abbrev = db.Column(db.String(10), unique=False) status = db.Column(db.Integer) address = db.Column(db.String(100), unique=False) openDate = db.Column(db.String(40), unique=False) statusDate = db.Column(db.String(40), unique=False) journalEntries = db.relationship('CoasterJournalEntry') def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
class CoasterTrack(db.Model): __tablename__ = 'coastertracks' id = db.Column(db.Integer, primary_key=True) coaster = db.Column(db.Integer, ForeignKey('coasterrides.id')) height = db.Column(db.Integer) inversions = db.Column(db.Integer) length = db.Column(db.Integer) speed = db.Column(db.Integer) elements = db.Column(db.String(500), unique=False) duration = db.Column(db.String(10), unique=False) verticalAngle = db.Column(db.Integer) drop = db.Column(db.Integer) modelLayout = db.Column(db.String(500), unique=False) configuration = db.Column(db.String(500), unique=False) modelCategory = db.Column(db.String(500), unique=False) coasterType = db.Column(db.String(500), unique=False) make = db.Column(db.String(500), unique=False) def as_dict(self): return {c.name: getattr(self, c.name) for c in self.__table__.columns}
try: park = CoasterPark.query.filter_by(rcdbID=coaster["parkid"]).one() cstr = CoasterRide(park=park.id, name=coaster["name"], rcdbID=coaster["rcdbid"], ridden=False, coasterOrRide=True, statusDate=coaster["statusDate"], openDate=coaster["openDate"], status=status) db.session.add(cstr) except NoResultFound: badParks.add(coaster["parkid"]) print("No result found for ", coaster["parkid"]) for coaster in coasters: for track in coaster["tracks"]: cstr = CoasterRide.query.filter_by(rcdbID=coaster["rcdbid"]).one() t = CoasterTrack(modelLayout=coaster["modelLayout"], configuration=coaster["configuration"], modelCategory=coaster["modelCategory"], make=coaster["make"], coasterType=coaster["coasterType"], coaster=cstr.id) length = db.Column(db.Integer) speed = db.Column(db.Integer) elements = db.Column(db.String(500), unique=False) duration = db.Column(db.String(10), unique=False) verticalAngle = db.Column(db.Integer) drop = db.Column(db.Integer) if "inversions" in track and track["inversions"] and len(track["inversions"]) > 0: t.inversions = int(re.sub('[^0-9]', '', str(track["inversions"]))) if "height" in track and track["height"] and len(track["height"]) > 0: t.height = int(re.sub('[^0-9]', '', str(track["height"]))) if "length" in track and track["length"] and len(track["length"]) > 0: t.length = int(re.sub('[^0-9]', '', str(track["length"]))) if "speed" in track and track["speed"] and len(track["speed"]) > 0: t.speed = int(re.sub('[^0-9]', '', str(track["speed"])))