Example #1
0
class Courier(Base):
    __tablename__ = 'courier'
    courier_id = Column(Integer, primary_key=True)
    courier_type = Column(Enum(CourierType, name='courier_type'),
                          nullable=False)
    regions = Column(ARRAY(Integer), nullable=False)
    working_hours = Column(ARRAY(String), nullable=False)

    def weight(self):
        weight_values = {'foot': 10, 'bike': 15, 'car': 50}

        if self.courier_type.foot:
            return weight_values['foot']
        elif self.courier_type.bike:
            return weight_values['bike']
        else:
            return weight_values['car']

    def to_dict(self) -> dict:
        return {
            'courier_id': self.courier_id,
            'courier_type': self.courier_type.name,
            'regions': self.regions,
            'working_hours': self.working_hours
        }
Example #2
0
class Product(Base):
    __tablename__ = 'product'

    STATUS_NEW = 1
    STATUS_SATELLITE = 2
    STATUS_REGULAR = 3

    id = Column(Integer, primary_key=True)
    domain = Column(String)
    code = Column(Integer)
    name = Column(String)
    description = Column(String)
    params = Column(JSONB, default='{}')
    status = Column(Integer, default=STATUS_NEW)
    images = Column(ARRAY(String), default=[])
    picker = Column(ARRAY(Integer), default=[])
    ref_count = Column(Integer, default=0)
    sizes = Column(ARRAY(String), default=[])
    brand_id = Column(Integer, ForeignKey('brand.id'))
    category_ids = Column(ARRAY(Integer), default=[])
    created_at = Column(DateTime, default=datetime.datetime.now)
    updated_at = Column(DateTime,
                        default=datetime.datetime.now,
                        onupdate=datetime.datetime.now)

    price = relationship('ProductPrice',
                         uselist=False,
                         back_populates='product')
    price_history = relationship('ProductPriceHistory',
                                 back_populates='product')
    brand = relationship('Brand')
    def random_update_order_parameters():
        from sqlalchemy import ARRAY

        t = table(
            "foo",
            column("data1", ARRAY(Integer)),
            column("data2", ARRAY(Integer)),
            column("data3", ARRAY(Integer)),
            column("data4", ARRAY(Integer)),
        )

        idx_to_value = [
            (t.c.data1, 5, 7),
            (t.c.data2, 10, 18),
            (t.c.data3, 8, 4),
            (t.c.data4, 12, 14),
        ]

        def combinations():
            while True:
                random.shuffle(idx_to_value)
                yield list(idx_to_value)

        return testing.combinations(*[
            (t, combination)
            for i, combination in zip(range(10), combinations())
        ],
                                    argnames="t, idx_to_value")
Example #4
0
class Movie(Base):
    __tablename__ = 'Movies'

    id = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    year = Column(SMALLINT, nullable=False)
    director = Column(String(100), nullable=False)
    duration = Column(SMALLINT, nullable=False)
    rating = Column(Float, nullable=False)
    users_votes = Column(Integer, nullable=False)
    budget = Column(String(50), nullable=False)
    opening_revenue = Column(String(50), nullable=False)
    total_revenue = Column(String(50), nullable=False)
    motion_picture_rating = Column(String(20), nullable=False)
    release_date = Column(String(20), nullable=False)
    genres = Column(ARRAY(String(20), dimensions=1), nullable=False)
    studios = Column(ARRAY(String(100), dimensions=1), nullable=False)
    cast = Column(ARRAY(String(100), dimensions=1), nullable=False)
    countries = Column(ARRAY(String(50), dimensions=1), nullable=False)

    you_tube_trailer_info = relationship('YouTubeMovieTrailerInfo', foreign_keys=[name,year],
            primaryjoin='Movie.name == YouTubeMovieTrailerInfo.name and Movie.year == YouTubeMovieTrailerInfo.year')

    tweets = relationship('Tweet', uselist=True, lazy='select', foreign_keys=[name,year],
            primaryjoin='Tweet.name == Movie.name and Movie.year == Tweet.year')

    def __repr__(self):
        return "<User(name='%s', fullname='%d', password='******')>" % (
            self.name, self.year, self.genres)

    def __init__(self, id, name, year, director, duration, rating,
        users_votes, budget, opening_revenue, total_revenue, motion_picture_rating,
        release_date, genres, studios, cast, countries):
        self.id = id
        self.name = name
        self.year = year
        self.director = director
        self.duration = duration
        self.rating = rating
        self.users_votes = users_votes
        self.budget = budget
        self.opening_revenue = opening_revenue
        self.total_revenue = total_revenue
        self.motion_picture_rating = motion_picture_rating
        self.release_date = release_date
        self.genres = genres
        self.studios = studios
        self.cast = cast
        self.countries = countries

    def count_sentiment_tweets(self):
        positive, negative,neutral = 0, 0, 0
        tweets_sentiment_count = {
            'positive': 0,
            'negative': 0,
            'neutral': 0
        }
        for tweet in self.tweets:
            tweets_sentiment_count[tweet.sentiment] += 1
        return tweets_sentiment_count
Example #5
0
class Inference(SmartBase):
    __tablename__ = "inference"
    id = Column(Integer, Sequence(f"{__tablename__}_id_seq"), primary_key=True)
    grd__id = Column(Integer, ForeignKey("grd.id"))
    ocn__id = Column(Integer, ForeignKey("ocn.id"))
    ml_pkls = Column(ARRAY(String))
    thresholds = Column(ARRAY(Integer))
    fine_pkl_idx = Column(Integer)
    chip_size_orig = Column(Integer)
    chip_size_reduced = Column(Integer)
    overhang = Column(Boolean)

    grd = relationship(
        "Grd",
        back_populates="inferences",
        foreign_keys=grd__id,
        enable_typechecks=False,
        cascade_backrefs=False,
    )
    ocn = relationship(
        "Ocn",
        back_populates="inferences",
        foreign_keys=ocn__id,
        enable_typechecks=False,
        cascade_backrefs=False,
    )
    posi_polys = relationship(
        "Posi_Poly",
        back_populates="inference",
        enable_typechecks=False,
        cascade_backrefs=False,
    )
Example #6
0
class Livro(Base):

    __tablename__ = 'livros'

    id = Column(Integer, primary_key=True)
    titulo = Column(String, nullable=False)
    ano_publicacao_original = Column(Integer, nullable=False)
    edicao = Column(Integer, nullable=False)
    editora_id = Column(Integer, ForeignKey('editoras.id'), nullable=False)
    ano_publicacao_edicao = Column(Integer, nullable=False)
    autores = Column(ARRAY(String), nullable=False)
    # idioma_original = Column(String, nullable=False)
    idioma = Column(String, nullable=False)
    tipo_id = Column(Integer, nullable=False)
    generos_id = Column(ARRAY(Integer))
    categoria_id = Column(Integer)
    estado_id = Column(Integer, nullable=False)
    exemplares = Column(Integer, default=0)
    preco = Column(Numeric(6, 2))
    paginas = Column(Integer)
    classificacao = Column(Numeric, default=0.0, nullable=False)
    capa = Column(LargeBinary, nullable=False)
    capa_extra1 = Column(LargeBinary)
    capa_extra2 = Column(LargeBinary)
    sinopse = Column(TEXT)
Example #7
0
class Characters(BaseDBModel, Base):
    __tablename__ = 'characters'

    deleted_at = Column(DateTime)

    name = Column(String)
    birthday = Column(Date)
    img = Column(String, nullable=True)
    status = Column(Enum(CharacterStatus), default=CharacterStatus.ALIVE)
    nickname = Column(String)
    occupation = Column(ARRAY(String))
    appearance = Column(ARRAY(String))
    portrayed = Column(String)
    category = Column(ARRAY(String))

    __table_args__ = (
        Index('uq_characters_name',
              text('lower(name)'),
              unique=True,
              postgresql_where=(deleted_at.is_(None))),
        Index('uq_characters_nickname',
              text('lower(nickname)'),
              unique=True,
              postgresql_where=(deleted_at.is_(None))),
    )
Example #8
0
class Dataset(Base):
    __tablename__ = "meta_dataset"
    id = Column(String, primary_key=True)
    type = Column(String)
    title = Column(String)
    description = Column(String)
    date_created = Column(DateTime)
    auth = Column(String)
    date_modified = Column(DateTime)
    license = Column(String)
    homepage = Column(String)
    language = Column(String)
    status = Column(String)
    version = Column(String)
    objective = Column(String)
    temporal_unit = Column(String)
    spatial = Column(String)
    legal_basis = Column(String)
    contact_point = Column(String)  # struct with name/email
    accrual_periodicity = Column(String)
    spatial_description = Column(String)
    spatial_coordinates = Column(String)
    theme = Column(ARRAY(String))
    publisher = Column(String)
    owner = Column(String)
    authorization_grantor = Column(String)
    keywords = Column(ARRAY(String))
    has_beginning = Column(DateTime)
    has_end = Column(DateTime)
    crs = Column(String)
class CatsStat(Base):
    __tablename__ = "cats_stat"
    tail_length_mean = Column("tail_length_mean", Numeric, primary_key=True)
    tail_length_median = Column("tail_length_median",
                                Numeric,
                                primary_key=True)
    tail_length_mode = Column("tail_length_mode",
                              ARRAY(Integer, as_tuple=True),
                              primary_key=True)
    whiskers_length_mean = Column("whiskers_length_mean",
                                  Numeric,
                                  primary_key=True)
    whiskers_length_median = Column("whiskers_length_median",
                                    Numeric,
                                    primary_key=True)
    whiskers_length_mode = Column("whiskers_length_mode",
                                  ARRAY(Integer, as_tuple=True),
                                  primary_key=True)

    def __init__(
        self,
        tail_length_mean,
        tail_length_median,
        tail_length_mode,
        whiskers_length_mean,
        whiskers_length_median,
        whiskers_length_mode,
    ):
        self.tail_length_mean = tail_length_mean
        self.tail_length_median = tail_length_median
        self.tail_length_mode = tail_length_mode
        self.whiskers_length_mean = whiskers_length_mean
        self.whiskers_length_median = whiskers_length_median
        self.whiskers_length_mode = whiskers_length_mode
Example #10
0
class Unit(db.Model, BaseColumns):
    __tablename__ = "unit"
    name = Column(String(100), nullable=False, unique=True)
    spell = Column(String(50), server_default='')
    category = Column(String(50), server_default='')
    tags = Column(ARRAY(String), server_default='{}')
    city = Column(String(100), server_default='')
    region = Column(String(100), server_default='')
    domain = Column(String(200), server_default='')
    domains = Column(ARRAY(String), server_default='{}')
    keywords = Column(ARRAY(String), server_default='{}')
    website_count = Column(Integer, server_default='0')

    def as_dict(self, fields=None):
        detail = {
            'id': self.id,
            'spell': self.spell,
            'keywords': self.keywords,
            'name': self.name,
            'category': self.category,
            'domains': self.domains,
            'tags': self.tags,
            'city': self.city,
            'region': self.region,
            'website_count': self.website_count
        }

        if not fields:
            return detail
        return {attr: detail[attr] for attr in fields if attr in detail}
Example #11
0
    async def _get_osm_objects_with_issues(self, changes):
        node_issues_set = {Issue(**i) for i in (await (await self.conn.execute(
            Issue.__table__.select().where(and_(
                Issue.__table__.c.handle == self.handle,
                Issue.__table__.c.date_closed is not None,
                Issue.__table__.c.affected_nodes.overlap(
                    cast(array(changes.affected_nodes), ARRAY(BigInteger))),
            ))
        )).fetchall())}
        way_issues_set = {Issue(**i) for i in (await (await self.conn.execute(
            Issue.__table__.select().where(and_(
                Issue.__table__.c.handle == self.handle,
                Issue.__table__.c.date_closed is not None,
                Issue.__table__.c.affected_ways.overlap(
                    cast(array(changes.affected_ways), ARRAY(BigInteger))),
            ))
        )).fetchall())}
        rel_issues_set = {Issue(**i) for i in (await (await self.conn.execute(
            Issue.__table__.select().where(and_(
                Issue.__table__.c.handle == self.handle,
                Issue.__table__.c.date_closed is not None,
                Issue.__table__.c.affected_rels.overlap(
                    cast(array(changes.affected_rels), ARRAY(BigInteger))),
            ))
        )).fetchall())}
        node_issues = {n: i for i in node_issues_set for n in i.affected_nodes}
        way_issues = {w: i for i in way_issues_set for w in i.affected_ways}
        rel_issues = {r: i for i in rel_issues_set for r in i.affected_rels}

        return node_issues, way_issues, rel_issues
class HistoricDUNS(Base):
    """ Legacy DUNS Records with their latest updates """
    __tablename__ = "historic_duns"

    duns_id = Column(Integer, primary_key=True)
    awardee_or_recipient_uniqu = Column(Text, index=True)
    legal_business_name = Column(Text)
    dba_name = Column(Text)
    activation_date = Column(Date)
    registration_date = Column(Date)
    expiration_date = Column(Date)
    last_sam_mod_date = Column(Date)
    address_line_1 = Column(Text)
    address_line_2 = Column(Text)
    city = Column(Text)
    state = Column(Text)
    zip = Column(Text)
    zip4 = Column(Text)
    country_code = Column(Text)
    congressional_district = Column(Text)
    business_types_codes = Column(ARRAY(Text))
    business_types = Column(ARRAY(Text))
    ultimate_parent_unique_ide = Column(Text)
    ultimate_parent_legal_enti = Column(Text)
    high_comp_officer1_full_na = Column(Text)
    high_comp_officer1_amount = Column(Text)
    high_comp_officer2_full_na = Column(Text)
    high_comp_officer2_amount = Column(Text)
    high_comp_officer3_full_na = Column(Text)
    high_comp_officer3_amount = Column(Text)
    high_comp_officer4_full_na = Column(Text)
    high_comp_officer4_amount = Column(Text)
    high_comp_officer5_full_na = Column(Text)
    high_comp_officer5_amount = Column(Text)
 def _select_from_database(self, main_db_cols, imdb_cols, input_json):
     query = self.session.query(MovieDatabase).join(ExtensionIMDB)
     arguments = [(main_db_cols, MovieDatabase), (imdb_cols, ExtensionIMDB)]
     try:
         for argument in arguments:
             for key in argument[0]:
                 value = input_json.get(key)
                 if isinstance(value, dict):
                     query = query.filter(
                         getattr(argument[1],
                                 key).between(value.get('lower'),
                                              value.get('higher')))
                 elif isinstance(value, list):
                     if any(isinstance(i, list) for i in value):
                         for inner_value in value:
                             query = query.filter(
                                 getattr(argument[1], key).overlap(
                                     cast(inner_value, ARRAY(String))))
                     else:
                         query = query.filter(
                             getattr(argument[1], key).overlap(
                                 cast(value, ARRAY(String))))
                 else:
                     query = query.filter(
                         getattr(argument[1], key) == value)
         result_list = dict()
         for item in query:
             result_list[item.movie_title] = item.as_dict()
         return json.dumps(result_list)
     except Exception:
         raise Exception
Example #14
0
    def test_update_to_expression_two(self):
        """test update from an expression.

        this logic is triggered currently by a left side that doesn't
        have a key.  The current supported use case is updating the index
        of a PostgreSQL ARRAY type.

        """

        from sqlalchemy import ARRAY

        t = table(
            "foo",
            column("data1", ARRAY(Integer)),
            column("data2", ARRAY(Integer)),
        )

        stmt = t.update().ordered_values(
            (t.c.data1[5], 7), (t.c.data2[10], 18)
        )
        dialect = default.StrCompileDialect()
        dialect.paramstyle = "qmark"
        dialect.positional = True
        self.assert_compile(
            stmt,
            "UPDATE foo SET data1[?]=?, data2[?]=?",
            dialect=dialect,
            checkpositional=(5, 7, 10, 18),
        )
Example #15
0
class FactApiLocations(Base):
    __tablename__ = 'idetect_fact_api_locations'

    fact = Column(Integer, primary_key=True)
    location_ids = Column(ARRAY(Integer))
    location_names = Column(ARRAY(String))
    location_ids_num = Column(Integer)
Example #16
0
class Submission(Base):
    __tablename__ = 'submissions'

    id = Column(Integer, primary_key=True)
    value = Column(String, nullable=False)
    category: SubmissionCategory = Column(Enum(SubmissionCategory))
    language: Language = Column(Enum(Language))
    lemmas: List[str] = Column(ARRAY(String))
    words: List[str] = Column(ARRAY(String))
    points = Column(Float, default=0, nullable=False)
    score = Column(Float, default=0, nullable=False)
    mwe_words: List[str] = Column(ARRAY(String))
    mwe_indices: List[int] = Column(ARRAY(Integer))
    conllu = Column(Text)
    hash = Column(String, default="", nullable=False)
    created = Column(DateTime, default=datetime.datetime.now, nullable=False)
    flagged = Column(Boolean, default=False, nullable=False)

    user_id = Column(Integer, ForeignKey('users.id'))
    user = relationship("User", back_populates="submissions")

    mwe_id = Column(Integer, ForeignKey("mwes.id"))
    mwe = relationship("Mwe", back_populates="submissions")

    reviews: List[Review] = relationship("Review", back_populates="submission")
    review_count: int = column_property(
        select([func.count(Review.id)]).where(Review.submission_id == id))

    def __repr__(self):
        return "<Value(id='%s', value='%s')>" % (self.id, self.value)
Example #17
0
class Movie(DeclarativeBase):
    """ Movie Model """
    __tablename__ = 'movies'
    #unique fields
    id = Column(Integer, primary_key=True)
    movie_title = Column('movie_title', String)
    movie_cover = Column('movie_cover', ARRAY(String))
    length = Column('length', Time)
    movie_trailer = Column('movie_trailer', String, nullable=True)
    description = Column('description', Text(), nullable=True)
    gallary_urls = Column("gallary_urls", ARRAY(String), nullable=True)
    #repetitive fields
    studio_id = Column(Integer, ForeignKey('studios.id'))

    director_id = Column(Integer, ForeignKey('directors.id'))

    performers = relationship("Performer", secondary=movie_cast_table, backref='movies')

    release_date_id = Column(Integer, ForeignKey('releasedates.id'))

    rating_id = Column(Integer, ForeignKey('ratings.id'))
    
    scenes = relationship("Scene", backref='movie', cascade_backrefs=False)

    genres = relationship("Genre", secondary=movie_genres_table, backref='movies',  cascade_backrefs=False)

    tags = relationship("Tag", secondary=movie_tags_table, backref='movies', cascade_backrefs=False)
Example #18
0
class Notifications(Base):
    __tablename__ = 'notifications'
    id_notifications = Column(Integer,
                              Sequence('notifications_id_notifications_seq'),
                              primary_key=True)
    address = Column(String, nullable=False)
    # matchingrule = Column(String, nullable=False)
    id_matchingrule = Column(Integer)
    modifytime = Column(TIMESTAMP(True))
    currcontent = Column(String)
    coloredcurrcontent = Column(String)
    currdocslinks = Column(String)
    detectedreplacedorinserted = Column(String)
    oldcontenttime = Column(TIMESTAMP(True))
    oldcontent = Column(String)
    coloredoldcontent = Column(String)
    olddocslinks = Column(String)
    detecteddeleted = Column(String)
    changes = Column(String, nullable=False)
    recipients = Column(ARRAY(String))
    ackers = Column(
        ARRAY(String)
    )  # It's an array in case of future use. Normally should have maximum 1 element

    def __repr__(self):
        return "<Notification(id_notifications='%s', address='%s', matchingrule='%s', id_matchingrule='%s'," \
               " modifytime='%s', oldcontent='%s', changes='%s' recipients='%s', ackers='%s')>" % \
               (self.id_notifications, self.address, self.matchingrule, self.id_matchingrule, self.modifytime,
                self.oldcontent, self.changes, self.recipients, self.ackers)
Example #19
0
 def create_schema(cls, db_engine, db_meta):
     cls.classroom_t = Table(
         cls.TABLE_NAME, db_meta,
         Column("id", Integer, primary_key=True, autoincrement=True),
         Column("name", String, nullable=False, autoincrement=False),
         Column("teacher", ForeignKey("tb_user.id"), nullable=False,
                autoincrement=False),
         Column("students_name", ARRAY(String), nullable=False,
                autoincrement=False),
         Column("students_cid", ARRAY(Integer), nullable=False,
                autoincrement=False),
         Column("students_sid", ARRAY(String), nullable=False,
                autoincrement=False),
         Column("folder", String, nullable=True, autoincrement=True,
                default=""),
         Column("comment", JSON, nullable=True, default={},
                autoincrement=True),
         Column("progress", Integer, nullable=False, default=10,
                autoincrement=True),
         Column("links", ARRAY(String), nullable=True, default=[],
                autoincrement=True),
         Column("create_at", DateTime, default=datetime.utcnow,
                autoincrement=True),
         Column("type", String, nullable=True, autoincrement=False))
     cls.classroom_t.create(db_engine, checkfirst=True)
     return cls.classroom_t
Example #20
0
class Sights(Base):
    __tablename__ = 'sights'

    id_sight = Column(Integer, primary_key=True)
    name = Column(String(100), nullable=False)
    tag = Column(ARRAY(Text))
    cost = Column(REAL)
    id_town = Column(Integer, ForeignKey(Town.id_town))
    cord_lat = Column(Integer)
    cord_long = Column(Integer)
    rating = Column(REAL)
    type_sight = Column(Text)
    urls = Column(ARRAY(Text))
    web_site = Column(Text)
    description = Column(Text)
    history = Column(Text)
    phone_number = Column(String(20))

    def serialize(self):
        return {
            'id_town': self.id_town,
            'id_sight': self.id_sight,
            'name': self.name,
            'tags': self.tag,
            'cost': self.cost,
            'coordinate': [self.cord_lat, self.cord_long],
            'rating': self.rating,
            'type': self.type_sight,
            'photo_urls': self.urls,
            'web_site': self.web_site,
            'description': self.description,
            'history': self.history,
            'phone_number': self.phone_number,
        }
class PubChemData(EntityBase):
    __tablename__ = 'pubchem_data'

    pubchem_id = Column(String(20), primary_key=True)

    names = Column(ARRAY(TEXT))

    mass = Column(Float)
    #weight = Column(Float)
    monoisotopic_mass = Column(Float)
    logp = Column(Float)

    # structure info -
    smiles = Column(ARRAY(TEXT))
    inchi = Column(TEXT)
    inchikey = Column(String(27))
    formula = Column(String(256))

    chebi_id = Column(String(20), ForeignKey('chebi_data.chebi_id'))
    kegg_id = Column(String(20), ForeignKey('kegg_data.kegg_id'))
    hmdb_id = Column(String(20), ForeignKey('hmdb_data.hmdb_id'))
    chemspider_id = Column(String(20))


    ref_etc = Column(JSON_GEN())

    def __init__(self, **kwargs):
        pass
Example #22
0
class Integers(Base):

    __tablename__ = 'Integers'
    id = Column(Integer, primary_key=True, autoincrement=True)
    surce_array = Column(ARRAY(Integer))
    result_array = Column(ARRAY(Integer))
    date_of_creation = Column(DateTime, default=datetime.datetime.utcnow)
Example #23
0
class ServerSetting(Base):
    server_id = Column(Integer, ForeignKey("server.id"))
    server = relationship(Server,
                          backref=backref("serversetting", uselist=True))
    bot_prefix = Column(ARRAY(String))
    modmail_server_id = Column(BigInteger)
    modmail_unanswered_cat_id = Column(BigInteger)
    modmail_in_progress_cat_id = Column(BigInteger)
    muted_role = Column(BigInteger)
    bot_bypass_role = Column(BigInteger)
    mod_channel = Column(BigInteger)
    wordfilter_data = Column(JSON)
    appeals_invite_code = Column(String)
    welcome_msg = Column(String)
    footer_msg = Column(String)
    antispam_quickmsg = Column(Boolean, default=False)
    antispam_mass_mentions = Column(Boolean, default=False)
    antispam_twitch = Column(Boolean, default=False)
    antispam_discord_invites = Column(Boolean, default=False)
    antispam_mixer = Column(Boolean, default=False)
    antispam_patreon = Column(Boolean, default=False)
    antispam_paypal = Column(Boolean, default=False)
    antispam_wordfilter = Column(Boolean, default=False)
    bot_id = Column(BigInteger)
    admin_role = Column(BigInteger)
    mod_role = Column(BigInteger)
    request_channel = Column(BigInteger)
    request_channel_allowed = Column(ARRAY(BigInteger))
    request_alert_channel = Column(BigInteger)
    activity_status = Column(ARRAY(String))
    activity_status_enabled = Column(Boolean, default=False)
    enabled = Column(
        Boolean,
        default=True,
        comment="Whether the bot is in the server, thus loading the settings",
    )
    antispam_quickmsg_modmail = Column(Boolean, default=True)
    welcome_msg_enabled = Column(Boolean, default=False)
    on_join_role_id = Column(BigInteger)
    on_join_role_enabled = Column(Boolean, default=False)
    cd_on_message_rate = Column(
        DECIMAL,
        comment=
        "on_message event number of messages per cd_on_message_time before on cooldown",
    )
    cd_on_message_time = Column(
        DECIMAL, comment="on_message event cooldown time, in seconds")
    antispam_mute_time = Column(
        String,
        comment=
        "Time to mute someone if antispam is tripped. Format is same as mute, e.g. '1h', '1d', '30m', etc",
    )
    upvote_emoji = Column(BigInteger)
    downvote_emoji = Column(BigInteger)
    question_emoji = Column(BigInteger)
    allow_downvotes = Column(Boolean, default=True)
    allow_questions = Column(Boolean, default=False)
    request_type = Column(sqlalchemy.Enum(RequestType),
                          default=RequestType.request)
Example #24
0
class ZoneRiskResults(Base):

    __tablename__ = 'zone_risk_results'

    # Columns
    risk_analysis_name = Column(String, primary_key=True)
    risk_criteria_list = Column(ARRAY(String))
    risk_scores_list = Column(ARRAY(String))
Example #25
0
class OsmDeuWay(Base):
    __tablename__ = 'osm_deu_ways'
    __table_args__ = {'schema': 'openstreetmap'}

    id = Column(BigInteger, primary_key=True, index=True)
    nodes = Column(ARRAY(BigInteger()), nullable=False, index=True)
    tags = Column(ARRAY(Text()))
    pending = Column(Boolean, nullable=False)
Example #26
0
class Courier(Base):
    __tablename__ = "Courier"

    id = Column(Integer, primary_key=True)
    type = Column(String, nullable=False)
    regions = Column(ARRAY(Integer), nullable=False)
    working_hours = Column(ARRAY(String), nullable=False)
    current_taken_weight = Column(Float, nullable=False, default=0)
Example #27
0
class AffaireType(Base):
    __tablename__ = 'affaire_type'
    __table_args__ = {'schema': 'infolica'}
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    nom = Column(Text, nullable=False)
    ordre = Column(BigInteger)
    reservation_numeros_types_id = Column(ARRAY(BigInteger))
    modif_affaire_type_id_vers = Column(ARRAY(BigInteger))
    logique_processus = Column(ARRAY(BigInteger))
Example #28
0
class Device(Base):
    __tablename__ = "device"

    id = Column(Integer, primary_key=True)
    type = Column(Enum(DeviceType))
    traits = Column(ARRAY(Enum(TraitType)))
    name = Column(String(255))
    nicknames = Column(ARRAY(String(255)))
    attributes = Column(MutableDict.as_mutable(JSONB))
    states = Column(MutableDict.as_mutable(JSONB))

    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship("User", foreign_keys=[user_id])

    def serialize_info(self):
        serialized = {
            "id": self.id,
            "type": self.type.value,
            "traits": [t.value for t in self.traits],
            "name": {
                "name": self.name,
                "nicknames": self.nicknames,
            },
            "willReportState": False,
            "attributes": {}
        }
        for attribute in self.attributes.values():
            serialized["attributes"].update(attribute)
        return serialized

    def serialize_status(self):
        serialized = {
            "on": True,
            "online": True,
            "status": "SUCCESS",
        }
        for state in self.states.values():
            serialized.update(state)
        return serialized

    def serialize(self):
        serialized = self.serialize_info()
        serialized["status"] = self.serialize_status()
        return serialized

    def execute_command(self, command, params):
        trait_enum = get_trait_by_command(command)
        if trait_enum not in self.traits:
            raise

        trait_class = get_class_by_trait(trait_enum)
        attributes = self.attributes.get(trait_enum.value, {})
        states = self.states.get(trait_enum.value, {})

        trait = trait_class(attributes, states)

        self.states[trait_enum.value] = trait.process_command(command, params)
Example #29
0
 def createTable(
         self, n,
         tablename):  #Table creation and mapping with QueenSolution class.
     table_q = Table(tablename, self.metadata,
                     Column('id_solution', Integer, primary_key=True),
                     Column('queen_rows', ARRAY(Integer)),
                     Column('queen_cols', ARRAY(Integer)))
     self.metadata.create_all(self.engine)
     orm.mapper(QueenSolution, table_q)
Example #30
0
class ModificationAffaireType(Base):
    __tablename__ = 'modification_affaire_type'
    __table_args__ = {'schema': 'infolica'}
    id = Column(BigInteger, primary_key=True, autoincrement=True)
    nom = Column(Text, nullable=False)
    ordre = Column(BigInteger)
    reservation_numeros_types_id = Column(ARRAY(BigInteger))
    affaire_source_type_id = Column(ARRAY(BigInteger))
    affaire_destination_type_id = Column(BigInteger, ForeignKey(AffaireType.id))