class TweetObject(BaseModel):
        username = peewee.TextField(unique=False, null=False)
        datapod_timestamp = peewee.DateTimeField(default=datetime.datetime.now)
        checksum = peewee.TextField(index=False, null=False)

        tweet_hash = peewee.TextField(index=True, unique=True, null=False)
        retweeted = peewee.BooleanField(null=True)
        source = peewee.TextField(
            null=True
        )  #<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>',
        entities = peewee.BlobField(null=True)
        symbols = peewee.BlobField(null=True)
        display_text_range = peewee.BlobField(null=True)
        favorite_count = peewee.TextField(null=True)
        id_str = peewee.TextField(null=True)
        possibly_sensitive = peewee.BooleanField(null=True)
        truncated = peewee.BooleanField(null=True)
        retweet_count = peewee.TextField(null=True)
        hashtags = peewee.TextField(null=True)
        user_mentions = peewee.TextField(null=True)

        created_at = peewee.DateTimeField(index=True, null=True)
        favorited = peewee.BooleanField(null=True)
        full_text = peewee.TextField(null=False)
        lang = peewee.TextField(null=True)
        in_reply_to_screen_name = peewee.TextField(null=True)
        in_reply_to_user_id_str = peewee.TextField(null=True)
 class OtherPosts(BaseModel):
     username = peewee.TextField(index=True, null=False)
     creation_timestamp = peewee.DateTimeField(index=True)
     data = peewee.BlobField(null=True)
     attachments = peewee.BlobField(null=True)
     title = peewee.TextField(null=True)
     datapod_timestamp = peewee.DateTimeField(default=datetime.datetime.now)
     checksum = peewee.TextField(index=True, null=False)
Exemplo n.º 3
0
class Torrent(peewee.Model):
    info_hash = peewee.CharField(max_length=40, unique=True)
    torrent_file = peewee.BlobField()
    download_path = peewee.TextField()
    name = peewee.TextField(null=True)
    resume_data = peewee.BlobField(null=True)

    class Meta:
        database = LT_DB
 class Images(BaseModel):
     title = peewee.TextField()
     username = peewee.TextField(index=True, null=False)
     uri = peewee.TextField(index=True, unique=True, null=False)
     creation_timestamp = peewee.DateTimeField(index=True)
     media_metadata = peewee.BlobField(null=True)
     comments = peewee.BlobField(null=True)
     datapod_timestamp = peewee.DateTimeField(default=datetime.datetime.now)
     checksum = peewee.TextField(index=True, null=False)
     chat_image = peewee.BooleanField(default=False)
     file_extension = peewee.TextField(null=True)
Exemplo n.º 5
0
class DataPeriod(BaseModel):
    """
    A Peewee database model for a distinct DataPeriod. DataPeriods are Area-related and contain datapoints across a span of time.
    """
    area = pw.ForeignKeyField(Area, related_name='dataperiods')
    date = pw.DateTimeField()

    test_ndvi_earlier = pw.BooleanField(null=True, default=0)
    test_ndvi_later = pw.BooleanField(null=True, default=0)
    test_rgb_earlier = pw.BooleanField(null=True, default=0)
    test_rgb_later = pw.BooleanField(null=True, default=0)

    area_sentinel = pw.BlobField(null=True)
    area_drone_ndvi = pw.BlobField(null=True)
    area_drone_rgb = pw.BlobField(null=True)

    block_sentinel_mean = pw.FloatField(null=True)
    block_sentinel_median = pw.FloatField(null=True)
    block_drone_ndvi_mean = pw.FloatField(null=True)
    block_drone_ndvi_median = pw.FloatField(null=True)
    block_drone_rgb_mean = pw.FloatField(null=True)
    block_drone_rgb_median = pw.FloatField(null=True)

    soil_type_cat = pw.CharField(null=True)
    soil_earthiness_cat = pw.CharField(null=True)
    soil_conductivity = pw.FloatField(null=True)
    soil_acidity = pw.FloatField(null=True)
    soil_calcium = pw.FloatField(null=True)
    soil_phosphorus = pw.FloatField(null=True)
    soil_potassium = pw.FloatField(null=True)
    soil_magnesium = pw.FloatField(null=True)
    soil_sulphur = pw.FloatField(null=True)
    soil_copper = pw.FloatField(null=True)
    soil_manganese = pw.FloatField(null=True)
    soil_zinc = pw.FloatField(null=True)
    soil_cec = pw.FloatField(null=True)
    soil_cec_ca = pw.FloatField(null=True)
    soil_cec_k = pw.FloatField(null=True)
    soil_cec_mg = pw.FloatField(null=True)
    soil_cec_na = pw.FloatField(null=True)

    weather_air_temperature_mean = pw.FloatField(null=True)
    weather_cloud_amount_mean = pw.FloatField(null=True)
    weather_dewpoint_temperature_mean = pw.FloatField(null=True)
    weather_gust_speed_mean = pw.FloatField(null=True)
    weather_horizontal_visibility_mean = pw.FloatField(null=True)
    weather_precipitation_amount_sum = pw.FloatField(null=True)
    weather_precipitation_intensity_mean = pw.FloatField(null=True)
    weather_pressure_mean = pw.FloatField(null=True)
    weather_relative_humidity_mean = pw.FloatField(null=True)
    weather_wind_direction_median = pw.FloatField(null=True)
    weather_wind_speed_mean = pw.FloatField(null=True)
Exemplo n.º 6
0
class JournalEntity(db.BaseModel):
    local_user = pw.ForeignKeyField(User, related_name='journals')
    version = pw.IntegerField()
    uid = pw.CharField(null=False, index=True)
    owner = pw.CharField(null=True)
    encrypted_key = pw.BlobField(null=True)
    content = pw.BlobField()
    new = pw.BooleanField(null=False, default=False)
    dirty = pw.BooleanField(null=False, default=False)
    deleted = pw.BooleanField(null=False, default=False)

    class Meta:
        indexes = ((('local_user', 'uid'), True), )
Exemplo n.º 7
0
 class Credentials(BaseModel):
     ##blocfileds will be stored in bytes
     name = peewee.TextField(null=True)
     email = peewee.TextField(null=False)
     username = peewee.CharField(unique=True)
     mnemonic = peewee.TextField(null=True)
     id_token = peewee.BlobField(null= True)
     access_token = peewee.BlobField(null= True)
     password_hash = peewee.TextField(null=False)
     password = peewee.TextField(null=False)
     refresh_token = peewee.BlobField(null= True)
     salt = peewee.TextField(null= True)
     address = peewee.TextField(null=True)
     encryption_key = peewee.TextField(null=True)
Exemplo n.º 8
0
class Decks(BaseModel):
    """
    json array of json objects containing the deck options
    """

    id = pv.AutoField()
    name = pv.TextField(collation="UNICASE")
    mtime_secs = pv.IntegerField(default=lambda: int(time()))
    usn = pv.IntegerField(default=0)
    common = pv.BlobField()
    kind = pv.BlobField()

    class Meta:
        indexes = [pv.SQL("CREATE INDEX idx_decks_name on decks (name)")]
Exemplo n.º 9
0
    class Transaction(pw.Model):
        id = pw.CharField(max_length=64, primary_key=True)
        version = pw.SmallIntegerField()
        block_id = pw.ForeignKeyField(
            backref="transaction_set",
            column_name="block_id",
            field="id",
            model=migrator.orm["blocks"],
        )
        sequence = pw.SmallIntegerField()
        timestamp = pw.IntegerField(index=True)
        sender_public_key = pw.CharField(index=True, max_length=66)
        recipient_id = pw.CharField(index=True, max_length=66, null=True)
        type = pw.SmallIntegerField()
        vendor_field = pw.CharField(max_length=255, null=True)
        amount = pw.BigIntegerField()
        fee = pw.BigIntegerField()
        serialized = pw.BlobField()
        asset = pw_pext.JSONField(null=True)

        class Meta:
            table_name = "transactions"
            indexes = [(
                ("sender_public_key", "recipient_id", "vendor_field",
                 "timestamp"),
                False,
            )]
Exemplo n.º 10
0
class RequestsModel(BaseModel):
    """Data model for documents from ``requests`` submission."""

    #: Original URL (c.f. :attr:`link.url <darc.link.Link.url>`).
    url: URLModel = peewee.ForeignKeyField(URLModel, backref='requests')
    #: Timestamp of the submission.
    timestamp: typing.Datetime = peewee.DateTimeField()

    #: Request method (normally ``GET``).
    method: str = peewee.CharField()
    #: Document data as :obj:`bytes`.
    document: bytes = peewee.BlobField()

    #: Conetent type.
    mime_type: str = peewee.CharField()
    #: If document is HTML or miscellaneous data.
    is_html: bool = peewee.BooleanField()

    #: Status code.
    status_code: int = peewee.IntegerField()
    #: Response reason string.
    reason: str = peewee.TextField()

    #: Response cookies.
    cookies: typing.Cookies = JSONField()
    #: Session cookies.
    session: typing.Cookies = JSONField()

    #: Request headers.
    request: typing.Headers = JSONField()
    #: Response headers.
    response: typing.Headers = JSONField()
Exemplo n.º 11
0
class Media(db.get_base_model()):
    type = peewee.ForeignKeyField(MediaType)
    preview = peewee.BlobField(null=True)
    remote_url = peewee.CharField(null=True)
    local_path = peewee.CharField(null=True)
    data = peewee.TextField(null=True)
    transfer_status = peewee.IntegerField(default=0)
    size = peewee.IntegerField(null=True)
    mimetype = peewee.CharField(null=True)
    filehash = peewee.CharField(null=True)
    filename = peewee.CharField(null=True)
    encoding = peewee.CharField(null=True)

    def toDict(self):
        media = {
            "type": self.type.name,
            "preview": self.preview,
            "remote_url": self.remote_url,
            "local_path": self.local_path,
            "data": self.data,
            "transfer_status": self.transfer_status,
            "size": self.size,
            "mimetype": self.mimetype,
            "filehash": self.filehash,
            "filename": self.filename,
            "encoding": self.encoding
        }
Exemplo n.º 12
0
class RequestsHistoryModel(BaseModel):
    """Data model for history records from ``requests`` submission."""

    #: History index number.
    index: int = peewee.IntegerField()
    #: Original record.
    model: RequestsModel = peewee.ForeignKeyField(RequestsModel, backref='history')

    #: Request URL.
    url: str = peewee.TextField()
    #: Timestamp of the submission.
    timestamp: typing.Datetime = peewee.DateTimeField()

    #: Request method (normally ``GET``).
    method: str = peewee.CharField()
    #: Document data as :obj:`bytes`.
    document: bytes = peewee.BlobField()

    #: Status code.
    status_code: int = peewee.IntegerField()
    #: Response reason string.
    reason: str = peewee.TextField()

    #: Response cookies.
    cookies: typing.Cookies = JSONField()

    #: Request headers.
    request: typing.Headers = JSONField()
    #: Response headers.
    response: typing.Headers = JSONField()
Exemplo n.º 13
0
class PaymentRequest(BaseModel):
    uid = peewee.BinaryUUIDField(primary_key=True)
    state = peewee.IntegerField(default=RequestState.UNKNOWN)
    description = peewee.TextField(null=True)
    date_expires = peewee.TimestampField(null=True, utc=True)
    date_created = peewee.TimestampField(utc=True)
    tx_hash = peewee.BlobField(null=True)
Exemplo n.º 14
0
class Message(MyModel):
    
    """
    Represents a message sent from one user to another, or to a group.
    """
    
    message_id = pw.BlobUUIDField(unique=True, verbose_name='Message UUID',
            help_text="This message's unique ID. This is set by the sender,"+\
            'kept track of by the server, and used to deduplicate '+\
            'messages by the receiver.')

    received_at = pw.DateTimeField(index=True,
            verbose_name='Message received by server at',
            help_text='When did the server finish storing the message? '+\
            '(For privacy or connectivity reasons, the message may '+\
            'arrive at the server at a different time to when it '+\
            'was composed -- timeouts should be computed based '+\
            'on time of reception, not of transmission.)'
            )

    sess_key = pw.BlobField(verbose_name='Session key',
            help_text='Encrypted session key, AKA content encryption key, '+\
            'for message blobs.')

    blob = pw.ForeignKeyField(MessageBlob, verbose_name='Message blob',
            help_text="Reference to this message's encrypted blob.")

    addressee = pw.ForeignKeyField(User, index=True,
            verbose_name='Message addressed to',
            help_text='What user should receive this message? '+\
            '(This is necessary to emit the correct push messages; '+\
            'the author of the message should be in the encrypted blob, '+\
            'along with an identity-confirming signature.)'
            )
Exemplo n.º 15
0
class RawMsg(BaseModel):
    """
    Raw message as fetched from IMAP server.
    """
    email_blob = pw.BlobField(help_text='Email blob with attachments removed')
    original_checksum = pw.CharField(
        help_text='Checksum of the original message from the server')
Exemplo n.º 16
0
class Store(pw.Model):
    """
        - Relacion 1+1
        user = pw.ForeignKeyField(User, primary_key=True)
    """
    # Relacion 1 a muchos
    user = pw.ForeignKeyField(User, related_name="stores")
    name = pw.CharField(max_length=50)
    address = pw.TextField()
    active = pw.BlobField(default=True)
    created_date = pw.DateTimeField(default=datetime.now())

    class Meta:
        database = db
        db_table = 'stores'

    @classmethod
    def new_store(cls, user, name, address):
        Store.create(user=user, name=name, address=address)

    @classmethod
    def get_store_by_userId(cls, id):
        try:
            store = Store.select().where(Store.user == id).get()
            if store:
                return store
            return "No hay tiendas"
        except:
            return "No se pudo realizar la consulta"

    def __str__(self):
        return self.name
Exemplo n.º 17
0
class StdModel(BaseModel):
    id = peewee.BlobField(primary_key=True)
    time = peewee.BigIntegerField(index=True, default=get_time)
    deleted_at = peewee.BigIntegerField(null=True, index=True)

    is_for_tests = peewee.BooleanField(default=False,
                                       help_text='单元测试专属账号,单元测试结束后删除')
Exemplo n.º 18
0
class File(BaseModel):
    id = peewee.AutoField(primary_key=True)
    path = peewee.TextField()
    contents = peewee.BlobField()
    mime_type = peewee.TextField(null=True)
    info = peewee.TextField(null=True, help_text="Output of `file`")
    service = peewee.ForeignKeyField(Service, backref='files', on_delete='CASCADE')
Exemplo n.º 19
0
class Group(db.get_base_model()):
    jid = peewee.CharField(null=False)
    picture = peewee.BlobField(null=True)
    subject = peewee.CharField(null=True)
    subject_owner_id = peewee.ForeignKeyField(Contact, null=True)
    subject_time = peewee.DateTimeField(null=True)
    created = peewee.DateTimeField(default=datetime.datetime.now())
Exemplo n.º 20
0
    class Transaction(pw.Model):
        id = pw.CharField(max_length=64, primary_key=True)
        version = pw.SmallIntegerField()
        block_id = pw.ForeignKeyField(backref='transaction_set', column_name='block_id', field='id', model=migrator.orm['blocks'])
        sequence = pw.SmallIntegerField()
        timestamp = pw.IntegerField(index=True)
        sender_public_key = pw.CharField(index=True, max_length=66)
        recipient_id = pw.ForeignKeyField(backref='transaction_set', column_name='recipient_id', field='address', model=migrator.orm['wallets'])
        type = pw.SmallIntegerField()
        vendor_field_hex = pw.BlobField(null=True)
        amount = pw.BigIntegerField()
        fee = pw.BigIntegerField()
        serialized = pw.BlobField()

        class Meta:
            table_name = "transactions"
            indexes = [(('sender_public_key', 'recipient_id', 'vendor_field_hex', 'timestamp'), False)]
Exemplo n.º 21
0
class WorkflowInput(BaseModel):
    class Meta:
        indexes = [(('key', 'workflow'), True)]

    name = pw.CharField()
    type = pw.ForeignKeyField(Type)
    default = pw.BlobField(null=True)
    workflow = pw.ForeignKeyField(Workflow, related_name='inputs')
Exemplo n.º 22
0
class Example(BaseModel):
    input_hash = orm.BigIntegerField()
    task_hash = orm.BigIntegerField()
    content = orm.BlobField()

    def load(self):
        content = convert_blob(self.content)
        return ujson.loads(content)
Exemplo n.º 23
0
class EntryEntity(db.BaseModel):
    journal = pw.ForeignKeyField(JournalEntity, related_name='entries')
    uid = pw.CharField(null=False, index=True)
    content = pw.BlobField()
    new = pw.BooleanField(null=False, default=False)

    class Meta:
        indexes = ((('journal', 'uid'), True), )
        order_by = ('id', )
Exemplo n.º 24
0
 class Picture(Table):
     digest = peewee.BlobField(unique=True)
     camera_make = peewee.TextField(null=True)
     camera_model = peewee.TextField(null=True)
     latitude = peewee.DoubleField(null=True)
     longitude = peewee.DoubleField(null=True)
     date = peewee.FloatField()
     day = peewee.IntegerField()
     file_path = peewee.TextField()
Exemplo n.º 25
0
class Media(BaseModel):
    data = pv.BlobField()
    h = pv.TextField()
    info = sqlite_ext.JSONField(default=dict)

    class Meta:
        indexes = [
            # pv.SQL('CREATE UNIQUE INDEX media_data_hash ON media (MD5(data))'),
        ]
Exemplo n.º 26
0
class SeleniumDocumentModel(BaseModel):
    """Data model for documents from ``selenium`` submission."""

    #: Original URL (c.f. :attr:`link.url <darc.link.Link.url>`).
    url: URLModel = peewee.ForeignKeyField(URLModel, backref='selenium')

    #: Document data as :obj:`bytes`.
    data: bytes = peewee.BlobField()
    #: Path to the document.
    path: str = peewee.CharField()
Exemplo n.º 27
0
class JobInput(BaseModel):
    class Meta:
        indexes = [(('job', 'key', 'order'), True)]
        order_by = ('job', 'key', 'order')


    key = pw.CharField()
    value = pw.BlobField()
    order = pw.IntegerField()
    job = pw.ForeignKeyField(Job, related_name='inputs')
Exemplo n.º 28
0
class Target(BaseModel):
    """
    A Peewee database model for a distinct Target. Targets are Area-related and provide the target yield information.
    """
    area = pw.ForeignKeyField(Area, related_name='target')

    area_yield = pw.BlobField(null=True)

    block_yield_mean = pw.FloatField(null=True)
    block_yield_median = pw.FloatField(null=True)
Exemplo n.º 29
0
class DeckConfig(BaseModel):
    """
    json array of json objects containing the deck options
    """

    id = pv.AutoField()
    name = pv.TextField(collation="UNICASE")
    mtime_secs = pv.IntegerField(default=lambda: int(time()))
    usn = pv.IntegerField(default=0)
    config = pv.BlobField()
Exemplo n.º 30
0
class GameSessionMembership(BaseModel):
    user = peewee.ForeignKeyField(User, backref="games")
    session = peewee.ForeignKeyField(GameSession, backref="players")
    row = peewee.IntegerField(null=True)
    admin = peewee.BooleanField()
    join_date = peewee.DateTimeField(default=_datetime_now)
    connection_state = peewee.TextField(null=True)
    inventory = peewee.BlobField(null=True)

    @property
    def as_json(self):
        return {
            "id": self.user.id,
            "name": self.user.name,
            "row": self.row,
            "admin": self.admin,
            # "inventory": self.inventory,
            "connection_state": self.connection_state,
        }

    @property
    def effective_name(self) -> str:
        return self.user.name

    @property
    def is_observer(self) -> bool:
        return self.row is None

    @classmethod
    def get_by_ids(cls, user_id: int,
                   session_id: int) -> "GameSessionMembership":
        return GameSessionMembership.get(
            GameSessionMembership.session == session_id,
            GameSessionMembership.user == user_id,
        )

    @classmethod
    def get_by_session_position(cls, session: GameSession,
                                row: int) -> "GameSessionMembership":
        return GameSessionMembership.get(
            GameSessionMembership.session == session,
            GameSessionMembership.row == row,
        )

    @classmethod
    def non_observer_members(
            cls, session: GameSession) -> Iterator["GameSessionMembership"]:
        yield from GameSessionMembership.select().where(
            GameSessionMembership.session == session,
            GameSessionMembership.row != None,
        )

    class Meta:
        primary_key = peewee.CompositeKey('user', 'session')
        constraints = [peewee.SQL('UNIQUE(session_id, row)')]