Esempio n. 1
0
class ConfigChannel(Model):
    id = AutoField()
    configname = CharField(max_length=100, collation="utf8mb4_general_ci")
    channelid = BigIntegerField(default=0)
    serverid = BigIntegerField()

    class Meta:
        database = connection
Esempio n. 2
0
class Guild(BaseModel):
    guild_id = BigIntegerField(unique=True)
    prefix = CharField(max_length=5, null=True, default='?')
    clear_spam = BooleanField(default=False)
    aggregate_clans = BooleanField(default=True)
    track_sherpas = BooleanField(default=False)
    admin_channel = BigIntegerField(unique=True, null=True)
    announcement_channel = BigIntegerField(unique=True, null=True)
Esempio n. 3
0
class StarboardBlock(ModelBase):
    guild_id = BigIntegerField()
    entity_id = BigIntegerField(
    )  # Technically this can be a channel too but, I'm not sure how to do that.
    actor_id = BigIntegerField()

    class Meta:
        indexes = ((('guild_id', 'entity_id'), True), )
Esempio n. 4
0
class Game(BaseModel):
    mode_id = IntegerField()
    instance_id = BigIntegerField(unique=True)
    date = DateTimeTZField()
    reference_id = BigIntegerField(null=True)

    class Meta:
        indexes = ((('mode_id', 'reference_id'), False), )
Esempio n. 5
0
class APIAuthInfo(BaseModel):
    id = PrimaryKeyField()
    botUid = BigIntegerField(help_text="关联的 Bot Uid")
    gid = BigIntegerField(help_text="群 id")
    cookie = CharField(help_text="API Cookie")

    class Meta:
        db_table = 'APIAuthInfo'
Esempio n. 6
0
class ArtChannel(Model):
    id = PrimaryKeyField()
    serverid = BigIntegerField()
    channelid = BigIntegerField(default=0)
    tag = CharField(max_length=30, collation="utf8mb4_general_ci")

    class Meta:
        database = connection
Esempio n. 7
0
class Transaction(Model):
    id = CharField(max_length=64, primary_key=True)
    version = SmallIntegerField()
    block_id = ForeignKeyField(Block)
    sequence = SmallIntegerField()
    timestamp = IntegerField(index=True)
    sender_public_key = CharField(max_length=66, index=True)
    recipient_id = CharField(max_length=66, null=True, index=True)
    type = SmallIntegerField()
    vendor_field = CharField(max_length=255, null=True)
    amount = BigIntegerField()
    fee = BigIntegerField()
    serialized = BytesField()
    asset = JSONField(null=True)

    class Meta:
        table_name = "transactions"
        indexes = ((
            ("sender_public_key", "recipient_id", "vendor_field", "timestamp"),
            False,
        ), )

    @classmethod
    def from_crypto(cls, transaction):
        # TODO: figure out how to improve this
        model = cls()
        model.id = transaction.id
        model.version = transaction.version
        model.block_id = transaction.block_id
        model.sequence = transaction.sequence
        model.timestamp = transaction.timestamp
        model.sender_public_key = transaction.sender_public_key
        model.recipient_id = transaction.recipient_id
        model.type = transaction.type
        model.vendor_field = transaction.vendor_field
        model.amount = transaction.amount
        model.fee = transaction.fee
        model.asset = transaction.asset
        # TODO: probably obsolete
        serialized = transaction.serialize()
        model.serialized = serialized
        return model

    @staticmethod
    def statistics():
        """Returns statistics about Blocks table
        """
        stats = Transaction.select(
            fn.COUNT(Transaction.id),
            fn.SUM(Transaction.fee),
            fn.SUM(Transaction.amount),
        ).scalar(as_tuple=True)

        return {
            "transactions_count": stats[0],
            "total_fee": stats[1],
            "total_amount": stats[2],
        }
class ChatNotesModel(BaseModel):
    room_id = BigIntegerField()
    user_id = BigIntegerField()
    message = TextField()
    # picture_url = CharField(max_length=128)
    time = CharField(max_length=20)  # 2018-01-01 23:00:01

    class Meta:
        db_table = 'chat_notes'
Esempio n. 9
0
class PlateRunToDesign(OperationsDBModel):
    design_pk = BigIntegerField(null=True)
    pk = PrimaryKeyField()
    plate_run_pk = BigIntegerField(null=True)

    class Meta:
        db_table = 'plate_run_to_design'
        indexes = ((('plate_run_pk', 'design_pk'), True), )
        schema = 'platedb'
Esempio n. 10
0
class DropboxChannel(Model):
    id = AutoField()
    serverid = BigIntegerField()
    sourcechannelid = BigIntegerField()
    targetchannelid = BigIntegerField(default=0)
    deletedelayms = SmallIntegerField(default=0)

    class Meta:
        database = connection
Esempio n. 11
0
class UserToken(BaseModel):
    id = BlobField(primary_key=True)
    user_id = BlobField(index=True)

    time = BigIntegerField(index=True)
    expire = BigIntegerField(null=True)

    first_meet_time = BigIntegerField(null=True)
    ip_first_meet = INETField(default=None, null=True)  # 注册IP
    ua_first_meet = TextField(null=True)

    last_access_time = BigIntegerField(null=True)
    ip_latest = INETField(default=None, null=True)
    ua_latest = TextField(null=True)

    class Meta:
        db_table = 'user_token'

    @classmethod
    def new(cls, user_id):
        create_time = int(time.time())
        expire_time = create_time + 30 * 24 * 60 * 60
        token = os.urandom(16)
        return UserToken.create(id=token, time=create_time, user_id=user_id, expire=expire_time)

    @classmethod
    def get_by_token(cls, token) -> Optional['UserToken']:
        if isinstance(token, str):
            try:
                token = to_bin(token)
            except binascii.Error:
                return

        t = cls.get_by_pk(token)
        if t and time.time() < t.expire:
            return t

    def get_token(self):
        return get_bytes_from_blob(self.id)

    async def init(self, view: AbstractSQLView):
        """
        从请求初始化信息
        :param view:
        :return:
        """
        # req = view._request
        self.first_meet_time = int(time.time())
        self.ip_first_meet = await view.get_ip()
        self.ua_first_meet = view.headers.get('User-Agent', None)
        self.save()

    async def access_save(self, view: AbstractSQLView):
        self.last_access_time = int(time.time())
        self.ip_latest = await view.get_ip()
        self.ua_latest = view.headers.get('User-Agent', None)
        self.save()
Esempio n. 12
0
File: round.py Progetto: tsifrer/ark
class Round(Model):
    id = AutoField(primary_key=True)
    public_key = CharField(max_length=66)
    balance = BigIntegerField()  # This is wallet.vote_balance
    round = BigIntegerField()

    class Meta:
        table_name = "rounds"
        indexes = ((("round", "public_key"), True), )
Esempio n. 13
0
class TwitterChannel(BaseModel):
    channel_id = BigIntegerField()
    twitter_id = BigIntegerField()
    guild_id = BigIntegerField()

    class Meta:
        indexes = (
            (('channel_id', 'twitter_id', 'guild_id'), True),
        )
Esempio n. 14
0
class Tag(DataBaseModel):
    f_id = BigAutoField(primary_key=True)
    f_name = CharField(max_length=100, index=True, unique=True)
    f_desc = TextField(null=True)
    f_create_time = BigIntegerField(default=current_timestamp())
    f_update_time = BigIntegerField(default=current_timestamp())

    class Meta:
        db_table = "t_tags"
Esempio n. 15
0
class UserGroups(BaseModel):
    """
    Local system user group relationships.
    """
    uid = BigIntegerField(help_text="User ID")  # {'index': True}
    gid = BigIntegerField(help_text="Group ID")  # {'index': True}

    class Meta:
        table_name = "user_groups"
Esempio n. 16
0
File: user.py Progetto: jellz/jetski
class StarboardBlock(BaseModel):
    guild_id = BigIntegerField()
    user_id = BigIntegerField()
    actor_id = BigIntegerField()

    class Meta:
        indexes = (
            (('guild_id', 'user_id'), True),
        )
class FollowingEntity(BaseModel):
    followed = ForeignKeyField(ProfileEntity)
    follower = ForeignKeyField(ProfileEntity)
    created_at = BigIntegerField(null=True)
    last_visit = BigIntegerField(null=True)
    deleted = BooleanField(null=True)

    class Meta:
        primary_key = CompositeKey('followed', 'follower')
        table_name = 'following'
Esempio n. 18
0
class Bind(BaseModel):
    id = PrimaryKeyField()
    group = IntegerField(help_text="群 id")
    member = BigIntegerField(help_text='成员 id', null=True)
    playerID = BigIntegerField(help_text='游戏内玩家 id')
    playerName = CharField(help_text='游戏内最新名称,若找不到尝试通过 player_id 匹配',
                           null=True)

    class Meta:
        db_table = 'bind'
Esempio n. 19
0
class Linux_ProcessEvents(ProcessEvents):
    fsuid = BigIntegerField(help_text="Filesystem user ID at process start")
    suid = BigIntegerField(help_text="Saved user ID at process start")
    fsgid = BigIntegerField(help_text="Filesystem group ID at process start")
    sgid = BigIntegerField(help_text="Saved group ID at process start")
    syscall = TextField(
        help_text="Syscall name: fork, vfork, clone, execve, execveat")

    class Meta:
        table_name = "process_events"
Esempio n. 20
0
class GuildMember(BaseModel):
    user_id = BigIntegerField()
    guild_id = BigIntegerField()

    level = BigIntegerField()
    points = BigIntegerField()

    class Meta:
        db_table = 'guild_members'
        primary_key = CompositeKey('user_id', 'guild_id')
Esempio n. 21
0
class DNSResolver(Model):
    domain = TextField(null=False)
    ip = TextField(null=False, index=True)
    mask = IntegerField(null=False, default=32)
    version = IntegerField(null=False, default=4)
    add = BigIntegerField(null=False, index=True)
    purge = BigIntegerField(null=True, index=True)

    class Meta(object):
        database = database_proxy
Esempio n. 22
0
class ArtChannel(Model):
    id = AutoField()
    serverid = BigIntegerField()
    # guild = ForeignKeyField(Guild, backref='artchannels')
    listenchannelid = BigIntegerField(default=0)
    collectionchannelid = BigIntegerField(default=0)
    tag = CharField(max_length=30, collation="utf8mb4_general_ci")

    class Meta:
        database = connection
Esempio n. 23
0
class LikeOnPostEntity(BaseModel):
    profile = ForeignKeyField(ProfileEntity)
    post = ForeignKeyField(PostEntity)
    created_at = BigIntegerField(null=True)
    last_visit = BigIntegerField(null=True)
    deleted = BooleanField(null=True)

    class Meta:
        table_name = "like_on_post"
        primary_key = CompositeKey('profile', 'post')
Esempio n. 24
0
class Package(DataBaseModel):
    f_id = AutoField(primary_key=True)
    f_version = CharField(max_length=20)
    f_start_time = BigIntegerField(null=True)
    f_end_time = BigIntegerField(null=True)
    f_elapsed = IntegerField(null=True)
    f_status = CharField(max_length=10)

    class Meta:
        db_table = "t_package"
Esempio n. 25
0
class Member(BaseModel):
    discord_id = BigIntegerField(null=True)
    bungie_id = BigIntegerField(null=True)
    bungie_username = CharField(null=True)
    xbox_id = BigIntegerField(null=True)
    xbox_username = CharField(unique=True, null=True)
    psn_id = BigIntegerField(null=True)
    psn_username = CharField(unique=True, null=True)
    blizzard_id = BigIntegerField(null=True)
    blizzard_username = CharField(unique=True, null=True)
    steam_id = BigIntegerField(null=True)
    steam_username = CharField(unique=True, null=True)
    stadia_id = BigIntegerField(null=True)
    stadia_username = CharField(unique=True, null=True)
    the100_id = BigIntegerField(unique=True, null=True)
    the100_username = CharField(unique=True, null=True)
    timezone = CharField(null=True)
    bungie_access_token = CharField(max_length=360, unique=True, null=True)
    bungie_refresh_token = CharField(max_length=360, unique=True, null=True)
    is_cross_save = BooleanField(default=False)
    primary_membership_id = BigIntegerField(unique=True, null=True)

    class Meta:
        indexes = ((('discord_id', 'bungie_id', 'xbox_id', 'psn_id',
                     'blizzard_id', 'steam_id', 'stadia_id', 'the100_id'),
                    True), )
Esempio n. 26
0
class File(BaseModel):
    """
    Interactive filesystem attributes and metadata.
    Examples:
        select * from file where path = '/etc/passwd'
        select * from file where directory = '/etc/'
        select * from file where path LIKE '/etc/%'
    """
    path = TextField(
        help_text="Absolute file path")  # {'required': True, 'index': True}
    directory = TextField(
        help_text="Directory of file(s)")  # {'required': True}
    filename = TextField(help_text="Name portion of file path")
    inode = BigIntegerField(help_text="Filesystem inode number")
    uid = BigIntegerField(help_text="Owning user ID")
    gid = BigIntegerField(help_text="Owning group ID")
    mode = TextField(help_text="Permission bits")
    device = BigIntegerField(help_text="Device ID (optional)")
    size = BigIntegerField(help_text="Size of file in bytes")
    block_size = IntegerField(help_text="Block size of filesystem")
    atime = BigIntegerField(help_text="Last access time")
    mtime = BigIntegerField(help_text="Last modification time")
    ctime = BigIntegerField(help_text="Last status change time")
    btime = BigIntegerField(help_text="(B)irth or (cr)eate time")
    hard_links = IntegerField(help_text="Number of hard links")
    symlink = IntegerField(help_text="1 if the path is a symlink, otherwise 0")
    type = TextField(help_text="File status")

    class Meta:
        table_name = "file"
Esempio n. 27
0
class FileEvents(BaseModel):
    """
    Track time/action changes to files specified in configuration data.
    """
    target_path = TextField(help_text="The path associated with the event")
    category = TextField(help_text="The category of the file defined in the config")
    action = TextField(help_text="Change action (UPDATE, REMOVE, etc)")
    transaction_id = BigIntegerField(help_text="ID used during bulk update")
    inode = BigIntegerField(help_text="Filesystem inode number")
    uid = BigIntegerField(help_text="Owning user ID")
    gid = BigIntegerField(help_text="Owning group ID")
    mode = TextField(help_text="Permission bits")
    size = BigIntegerField(help_text="Size of file in bytes")
    atime = BigIntegerField(help_text="Last access time")
    mtime = BigIntegerField(help_text="Last modification time")
    ctime = BigIntegerField(help_text="Last status change time")
    md5 = TextField(help_text="The MD5 of the file after change")
    sha1 = TextField(help_text="The SHA1 of the file after change")
    sha256 = TextField(help_text="The SHA256 of the file after change")
    hashed = IntegerField(help_text="1 if the file was hashed, 0 if not, -1 if hashing failed")
    time = BigIntegerField(help_text="Time of file event")
    eid = TextField(help_text="Event ID")  # {'hidden': True}

    class Meta:
        table_name = "file_events"
Esempio n. 28
0
class MemoryInfo(BaseModel):
    """
    Main memory information in bytes.
    """
    memory_total = BigIntegerField(
        help_text="Total amount of physical RAM, in bytes")
    memory_free = BigIntegerField(
        help_text=
        "The amount of physical RAM, in bytes, left unused by the system")
    buffers = BigIntegerField(
        help_text="The amount of physical RAM, in bytes, used for file buffers"
    )
    cached = BigIntegerField(
        help_text="The amount of physical RAM, in bytes, used as cache memory")
    swap_cached = BigIntegerField(
        help_text="The amount of swap, in bytes, used as cache memory")
    active = BigIntegerField(
        help_text=
        "The total amount of buffer or page cache memory, in bytes, that is in active use"
    )
    inactive = BigIntegerField(
        help_text=
        "The total amount of buffer or page cache memory, in bytes, that are free and available"
    )
    swap_total = BigIntegerField(
        help_text="The total amount of swap available, in bytes")
    swap_free = BigIntegerField(
        help_text="The total amount of swap free, in bytes")

    class Meta:
        table_name = "memory_info"
Esempio n. 29
0
class Order(Model):
    class Meta:
        database = db
        table_name = "orders"

    apptransid = CharField(primary_key=True)
    zptransid = CharField()
    description = CharField()
    amount = BigIntegerField()
    timestamp = BigIntegerField()
    channel = IntegerField()
Esempio n. 30
0
class PartyInfo(DataBaseModel):
    f_party_id = CharField(max_length=100, primary_key=True)
    # f_job_id = CharField(max_length=100)
    f_role = CharField(max_length=20)
    f_modules = JSONField()
    f_version = CharField(max_length=20)
    f_create_time = BigIntegerField(null=True)
    f_update_time = BigIntegerField(null=True)

    class Meta:
        db_table = "t_party_info"