class Flag(db.Model): __tablename__ = 'ask_reply_flag' reply_id = db.Column(db.Integer, db.ForeignKey(Reply.id), primary_key = True) user_id = db.Column(db.Integer, db.ForeignKey(User.id), primary_key = True) def __repr__(self): return '<Flag %r by user:%r>' % (self.reply_id, self.user_id)
class Crosswalk_oc(db.Model): __tablename__ = 'crosswalk_oc' cbo_id = db.Column(db.String(4), db.ForeignKey(Cbo.id), primary_key = True) course_hedu_id = db.Column(db.String(6), db.ForeignKey(Course_hedu.id), primary_key = True) def get_id(self, dataset): if dataset == "rais": return self.course_hedu_id return self.cbo_id
class Ybi_reqs(db.Model, AutoSerialize): __tablename__ = 'rais_ybi_required' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(8), db.ForeignKey(Bra.id), primary_key=True) cnae_id = db.Column(db.String(5), db.ForeignKey(Cnae.id), primary_key=True) required_bras = db.Column(db.String(255)) def __repr__(self): return '<Ybi_reqs %d.%s.%s>' % (self.year, self.bra_id, self.cnae_id)
class Ybc_hedu(Hedu): __tablename__ = 'hedu_ybc' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) course_hedu_id = db.Column(db.String(6), db.ForeignKey(Course_hedu.id), primary_key=True) bra_id_len = db.Column(db.Integer(1)) course_hedu_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybc {}.{}.{}>'.format(self.year, self.bra_id, self.course_hedu_id)
class Bs(db.Model, AutoSerialize): __tablename__ = 'attrs_bs' bra_id = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) stat_id = db.Column(db.String(20), db.ForeignKey(Stat.id), primary_key=True) stat_val = db.Column(db.String(40)) def __repr__(self): return "<Bs {}.{}>".format(self.bra_id, self.stat_id)
class Ybs(db.Model, AutoSerialize): __tablename__ = 'attrs_ybs' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) stat_id = db.Column(db.String(20), db.ForeignKey(Stat.id), primary_key=True) stat_val = db.Column(db.Float) def __repr__(self): return "<Ybs {}.{}.{}>".format(self.year, self.bra_id, self.stat_id)
class Ybu(Hedu): __tablename__ = 'hedu_ybu' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) university_id = db.Column(db.String(5), db.ForeignKey(University.id), primary_key=True) bra_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybu {}.{}.{}>'.format(self.year, self.bra_id, self.university_id)
class Yuc(Hedu): __tablename__ = 'hedu_yuc' year = db.Column(db.Integer(4), primary_key=True) university_id = db.Column(db.String(5), db.ForeignKey(University.id), primary_key=True) course_hedu_id = db.Column(db.Integer(6), db.ForeignKey(Course_hedu.id), primary_key=True) course_hedu_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Yuc {}.{}.{}>'.format(self.year, self.university_id, self.course_hedu_id)
class Yio(BaseRais, db.Model, AutoSerialize): __tablename__ = 'rais_yio' cnae_id = db.Column(db.String(5), db.ForeignKey(Cnae.id), primary_key=True) cbo_id = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) importance = db.Column(db.Float()) cnae_id_len = db.Column(db.Integer(1)) cbo_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Yio %d.%s.%s>' % (self.year, self.cnae_id, self.cbo_id)
class Ybo(BaseRais, db.Model, AutoSerialize): __tablename__ = 'rais_ybo' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(8), db.ForeignKey(Bra.id), primary_key=True) cbo_id = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) bra_id_len = db.Column(db.Integer(1)) cbo_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybo %d.%s.%s>' % (self.year, self.bra_id, self.cbo_id)
class Ypp(db.Model, AutoSerialize): __tablename__ = 'attrs_ypp' year = db.Column(db.Integer(4), primary_key=True) hs_id = db.Column(db.String(8), db.ForeignKey(Hs.id), primary_key=True) hs_id_target = db.Column(db.String(8), db.ForeignKey(Hs.id), primary_key=True) prox_bra = db.Column(db.Float) def __repr__(self): return "<Ypp {}.{}.{}>".format(self.year, self.hs_id, self.hs_id_target)
class Yoo(db.Model, AutoSerialize): __tablename__ = 'attrs_yoo' year = db.Column(db.Integer(4), primary_key=True) cbo_id = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) cbo_id_target = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) prox_bra = db.Column(db.Float) def __repr__(self): return "<Yoo {}.{}.{}>".format(self.year, self.cbo_id, self.cbo_id_target)
class Ybs(Sc): __tablename__ = 'sc_ybs' bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) school_id = db.Column(db.String(8), db.ForeignKey(School.id), primary_key=True) bra_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybs %d.%s.%s>' % (self.year, self.bra_id, self.school_id)
class Yww(db.Model, AutoSerialize): __tablename__ = 'attrs_yww' year = db.Column(db.Integer(4), primary_key=True) wld_id = db.Column(db.String(5), db.ForeignKey(Wld.id), primary_key=True) wld_id_target = db.Column(db.String(5), db.ForeignKey(Wld.id), primary_key=True) prox_bra = db.Column(db.Float) def __repr__(self): return "<Yww {}.{}.{}>".format(self.year, self.wld_id, self.wld_id_target)
class Ybc_sc(Sc): __tablename__ = 'sc_ybc' bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) course_sc_id = db.Column(db.String(5), db.ForeignKey(Course_sc.id), primary_key=True) bra_id_len = db.Column(db.Integer(1)) course_sc_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybc %d.%s.%s>' % (self.year, self.bra_id, self.course_sc_id)
class Ypw(db.Model, AutoSerialize): __tablename__ = 'secex_ypw' year = db.Column(db.Integer(4), primary_key=True) hs_id = db.Column(db.String(6), db.ForeignKey(Hs.id), primary_key=True) wld_id = db.Column(db.String(5), db.ForeignKey(Wld.id), primary_key=True) val_usd = db.Column(db.Numeric(16, 2)) val_usd_growth_pct = db.Column(db.Float()) val_usd_growth_pct_5 = db.Column(db.Float()) val_usd_growth_val = db.Column(db.Numeric(16, 2)) val_usd_growth_val_5 = db.Column(db.Numeric(16, 2)) def __repr__(self): return '<Ypw %d.%s.%s>' % (self.year, self.hs_id, self.wld_id)
class Ysc(Sc): __tablename__ = 'sc_ysc' school_id = db.Column(db.String(8), db.ForeignKey(School.id), primary_key=True) course_sc_id = db.Column(db.String(5), db.ForeignKey(Course_sc.id), primary_key=True) course_sc_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ysc %d.%s>' % (self.year, self.school_id)
class Yuu(db.Model, AutoSerialize): __tablename__ = 'attrs_yuu' year = db.Column(db.Integer(4), primary_key=True) university_id = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) university_id_target = db.Column(db.String(6), db.ForeignKey(Cbo.id), primary_key=True) prox_course_hedu = db.Column(db.Float) def __repr__(self): return "<Yuu {}.{}.{}>".format(self.year, self.cbo_id, self.cbo_id_target)
class Ybi(BaseRais, db.Model, AutoSerialize): __tablename__ = 'rais_ybi' bra_id = db.Column(db.String(8), db.ForeignKey(Bra.id), primary_key=True) cnae_id = db.Column(db.String(5), db.ForeignKey(Cnae.id), primary_key=True) rca = db.Column(db.Float()) distance = db.Column(db.Float()) opp_gain = db.Column(db.Float()) bra_id_len = db.Column(db.Integer(1)) cnae_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Ybi %d.%s.%s>' % (self.year, self.bra_id, self.cnae_id)
class Reply(db.Model, AutoSerialize): __tablename__ = 'ask_reply' id = db.Column(db.Integer, primary_key=True) parent_id = db.Column(db.Integer) body = db.Column(db.Text()) timestamp = db.Column(db.DateTime) user_id = db.Column(db.Integer, db.ForeignKey(User.id)) question_id = db.Column(db.Integer, db.ForeignKey(Question.id)) hidden = db.Column(db.SmallInteger, default=0) votes = db.relationship( "Vote", primaryjoin="and_(Reply.id==Vote.type_id, Vote.type=={0})".format( TYPE_REPLY), foreign_keys=[Vote.type_id], backref='reply', lazy='dynamic') flags = db.relationship("Flag", backref='reply', lazy='dynamic') def slug(self): return Question.query.get(self.question_id).slug def __repr__(self): return '<Reply %r>' % (self.id) def flagged(self): if g.user.is_authenticated: flag = Flag.query.filter_by(reply_id=self.id, user_id=g.user.id).first() if flag: return True return False def voted(self): if g.user.is_authenticated: vote = Vote.query.filter_by(type=1, type_id=self.id, user_id=g.user.id).first() if vote: return True return False def serialize(self): auto_serialized = super(Reply, self).serialize() auto_serialized["user"] = self.user.serialize() auto_serialized["votes"] = len(self.votes.all()) auto_serialized["flags"] = len(self.flags.all()) return auto_serialized
class Ybb(db.Model, AutoSerialize): __tablename__ = 'attrs_ybb' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) bra_id_target = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) prox_cnae = db.Column(db.Float) prox_cbo = db.Column(db.Float) prox_hs = db.Column(db.Float) prox_wld = db.Column(db.Float) def __repr__(self): return "<Ybb {}.{}.{}>".format(self.year, self.bra_id, self.bra_id_target)
class Vote(db.Model): __tablename__ = 'ask_vote' type = db.Column(db.SmallInteger, primary_key = True, default=TYPE_QUESTION) type_id = db.Column(db.Integer, primary_key = True) user_id = db.Column(db.Integer, db.ForeignKey(User.id), primary_key = True) def __repr__(self): return '<Vote %r:%r by:%r>' % (self.type, self.type_id, self.user_id)
class Yb(db.Model, AutoSerialize): __tablename__ = 'attrs_yb' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) population = db.Column(db.Integer) def __repr__(self): return '<Yb %r.%r>' % (self.year, self.bra_id)
class Starred(db.Model, AutoSerialize): __tablename__ = 'account_starred' app_id = db.Column(db.String(80), primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey(User.id), primary_key=True) app_name = db.Column(db.String(255)) timestamp = db.Column(db.DateTime) def __repr__(self): return '<App %r starred by %r>' % (self.app_id, self.user.nickname)
class Ys(Sc): __tablename__ = 'sc_ys' school_id = db.Column(db.String(8), db.ForeignKey(School.id), primary_key=True) def __repr__(self): return '<Ys %d.%s.%s>' % (self.year, self.school_id)
class Yb_sc(Sc): __tablename__ = 'sc_yb' bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) num_schools = db.Column(db.Integer(11)) bra_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Yb {0}.{1}>'.format(self.year, self.bra_id)
class Ybp(db.Model, AutoSerialize): __tablename__ = 'secex_ybp' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(8), db.ForeignKey(Bra.id), primary_key=True) hs_id = db.Column(db.String(6), db.ForeignKey(Hs.id), primary_key=True) val_usd = db.Column(db.Numeric(16, 2)) rca = db.Column(db.Float()) rca_wld = db.Column(db.Float()) distance = db.Column(db.Float()) distance_wld = db.Column(db.Float()) opp_gain = db.Column(db.Float()) opp_gain_wld = db.Column(db.Float()) val_usd_growth_pct = db.Column(db.Float()) val_usd_growth_pct_5 = db.Column(db.Float()) val_usd_growth_val = db.Column(db.Numeric(16, 2)) val_usd_growth_val_5 = db.Column(db.Numeric(16, 2)) def __repr__(self): return '<Ybp %d.%s.%s>' % (self.year, self.bra_id, self.hs_id)
class Yb_hedu(Hedu): __tablename__ = 'hedu_yb' year = db.Column(db.Integer(4), primary_key=True) bra_id = db.Column(db.String(9), db.ForeignKey(Bra.id), primary_key=True) num_universities = db.Column(db.Integer(11)) bra_id_len = db.Column(db.Integer(1)) def __repr__(self): return '<Yb {}.{}>'.format(self.year, self.bra_id)
class Distances(db.Model): __tablename__ = 'attrs_bb' bra_id_origin = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) bra_id_dest = db.Column(db.String(10), db.ForeignKey(Bra.id), primary_key=True) distance = db.Column(db.Float()) def __repr__(self): return '<Bra_Dist %r-%r:%g>' % (self.bra_id_origin, self.bra_id_dest, self.distance) def serialize(self): return { "bra_id_origin": self.bra_id_origin, "bra_id_dest": self.bra_id_dest, "distance": self.distance }
class UI(db.Model, AutoSerialize): __tablename__ = 'apps_ui' id = db.Column(db.Integer, db.ForeignKey(Build.id), primary_key=True) type = db.Column(db.String(20)) values = db.Column(db.String(255)) def serialize(self, **kwargs): auto_serialized = super(UI, self).serialize() auto_serialized["values"] = ast.literal_eval(self.values) return auto_serialized def __repr__(self): return '<Build %r: %r>' % (self.type, self.values)