Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fsequenceid = IntegerField(column_name='fSequenceID')
fstarttime = DateTimeField(column_name='fStartTime', null=True)
fstoptime = DateTimeField(column_name='fStopTime', null=True)
class Meta:
table_name = 'FillStarStatus'
indexes = (
(('fnight', 'fsequenceid'), True),
)
primary_key = CompositeKey('fnight', 'fsequenceid')
class MeasurementType(FactDataModel):
fisunlimited = IntegerField(column_name='fIsUnlimited')
fmeasurementtype = CharField(column_name='fMeasurementType')
fmeasurementtypekey = PrimaryKeyField(column_name='fMeasurementTypeKey')
fmeasurementtypename = CharField(column_name='fMeasurementTypeName', unique=True)
fneedssource = IntegerField(column_name='fNeedsSource')
class Meta:
table_name = 'MeasurementType'
class ObservationTimes(FactDataModel):
fmjd = IntegerField(column_name='fMjd')
fmoonrise = DateTimeField(column_name='fMoonRise')
fmoonset = DateTimeField(column_name='fMoonSet')
fnight = PrimaryKeyField(column_name='fNight')
fnumdarkhours = FloatField(column_name='fNumDarkHours')
fstartdarknight = DateTimeField(column_name='fStartDarkNight')
fstartdarktime = DateTimeField(column_name='fStartDarkTime')
fstartobservation = DateTimeField(column_name='fStartObservation')
mid = pw.PrimaryKeyField()
content = pw.TextField(null=True)
mlink = pw.CharField(max_length=255, null=True)
mtype = pw.IntegerField(null=True)
posted = pw.DateTimeField(null=True)
read = pw.DateTimeField(null=True)
receivedby = pw.ForeignKeyField(backref='message_set', column_name='receivedby', field='uid', model=migrator.orm['user'], null=True)
sentby = pw.ForeignKeyField(backref='user_sentby_set', column_name='sentby', field='uid', model=migrator.orm['user'], null=True)
subject = pw.CharField(max_length=255, null=True)
class Meta:
table_name = "message"
@migrator.create_model
class SiteLog(pw.Model):
lid = pw.PrimaryKeyField()
action = pw.IntegerField(null=True)
desc = pw.CharField(max_length=255, null=True)
link = pw.CharField(max_length=255, null=True)
time = pw.DateTimeField()
uid = pw.ForeignKeyField(backref='sitelog_set', column_name='uid', field='uid', model=migrator.orm['user'], null=True)
target = pw.ForeignKeyField(backref='sitelog_set', column_name='target_uid', field='uid', model=migrator.orm['user'], null=True)
class Meta:
table_name = "site_log"
@migrator.create_model
class SiteMetadata(pw.Model):
xid = pw.PrimaryKeyField()
key = pw.CharField(max_length=255, null=True)
value = pw.CharField(max_length=255, null=True)
db_table = 'collection'
class SampleSet(MySQLModel):
sample_set = PrimaryKeyField(db_column='sample_set_pk')
dataset = ForeignKeyField(Dataset, db_column='dataset_pk', to_field='dataset', related_name='sample_sets')
collection = ForeignKeyField(Collection, db_column='collection_pk', to_field='collection', related_name='sample_sets')
sample_size = IntegerField()
phenotype = CharField(null=True)
class Meta:
db_table = 'sample_set'
class DatasetFile(MySQLModel):
dataset_file = PrimaryKeyField(db_column='dataset_file_pk')
dataset_version = ForeignKeyField(DatasetVersion, db_column='dataset_version_pk', to_field='dataset_version', related_name='files')
name = CharField()
uri = CharField()
bytes = IntegerField()
class Meta:
db_table = 'dataset_file'
class UserAccessLog(MySQLModel):
user_access_log = PrimaryKeyField(db_column='user_access_log_pk')
user = ForeignKeyField(User, db_column='user_pk', to_field='user', related_name='access_logs')
dataset = ForeignKeyField(Dataset, db_column='dataset_pk', to_field='dataset', related_name='access_logs')
action = EnumField(null=True, values=['access_requested','access_granted','access_revoked','private_link'])
ts = DateTimeField()
import datetime
import peewee
from windseed.settings import db
class Model(peewee.Model):
"""
Common db model:
uid - primary key
uts - timestamp (auto on creation)
"""
uid = peewee.PrimaryKeyField(unique=True, index=True)
uts = peewee.DateTimeField(default=datetime.datetime.now, index=True)
class Meta:
database = db.pool
order_by = ('-uts', )
dataset = ForeignKeyField(Dataset, db_column='dataset_pk', to_field='dataset', related_name='versions')
version = CharField()
description = TextField()
terms = TextField()
var_call_ref = CharField(null=True)
available_from = DateTimeField()
ref_doi = CharField(null=True)
data_contact_name = CharField(null=True)
data_contact_link = CharField(null=True)
class Meta:
db_table = 'dataset_version'
class Collection(MySQLModel):
collection = PrimaryKeyField(db_column = 'collection_pk')
name = CharField(null = True)
ethnicity = CharField(null = True)
class Meta:
db_table = 'collection'
class SampleSet(MySQLModel):
sample_set = PrimaryKeyField(db_column='sample_set_pk')
dataset = ForeignKeyField(Dataset, db_column='dataset_pk', to_field='dataset', related_name='sample_sets')
collection = ForeignKeyField(Collection, db_column='collection_pk', to_field='collection', related_name='sample_sets')
sample_size = IntegerField()
phenotype = CharField(null=True)
class Meta:
db_table = 'sample_set'
def gen_field(self, field):
""" Function description. """
if isinstance(field.scheme, AutoField)\
and self.__mixer and self.__mixer.params.get('commit'):
return field.name, SKIP_VALUE
return super(TypeMixer, self).gen_field(field)
import eventlet
import logging
logging.basicConfig(level=logging.WARN)
logger = logging.getLogger('data_server')
eventlet.monkey_patch()
############################################################
#
# Database
#
############################################################
db = peewee.SqliteDatabase('data_server.db')
class Memory(peewee.Model):
id = peewee.PrimaryKeyField()
data = peewee.BlobField()
generation = peewee.IntegerField()
date = peewee.DateTimeField(default=datetime.datetime.now)
class Meta:
database = db
class Weights(peewee.Model):
id = peewee.PrimaryKeyField()
data = peewee.BlobField()
generation = peewee.IntegerField()
date = peewee.DateTimeField(default=datetime.datetime.now)
class Meta:
database = db
db_table = 'dataset_file'
class UserAccessLog(MySQLModel):
user_access_log = PrimaryKeyField(db_column='user_access_log_pk')
user = ForeignKeyField(User, db_column='user_pk', to_field='user', related_name='access_logs')
dataset = ForeignKeyField(Dataset, db_column='dataset_pk', to_field='dataset', related_name='access_logs')
action = EnumField(null=True, values=['access_requested','access_granted','access_revoked','private_link'])
ts = DateTimeField()
class Meta:
db_table = 'user_access_log'
class UserConsentLog(MySQLModel):
user_consent_log = PrimaryKeyField(db_column='user_consent_log_pk')
user = ForeignKeyField(User, db_column='user_pk', to_field='user', related_name='consent_logs')
dataset_version = ForeignKeyField(DatasetVersion, db_column='dataset_version_pk', to_field='dataset_version', related_name='consent_logs')
ts = DateTimeField()
class Meta:
db_table = 'user_consent_log'
class UserDownloadLog(MySQLModel):
user_download_log = PrimaryKeyField(db_column='user_download_log_pk')
user = ForeignKeyField(User, db_column='user_pk', to_field='user', related_name='download_logs')
dataset_file = ForeignKeyField(DatasetFile, db_column='dataset_file_pk', to_field='dataset_file', related_name='download_logs')
ts = DateTimeField()
class Meta:
db_table = 'user_download_log'
class Checkin(peewee.Model):
"""
{
'type': 'checkin',
'business_id': (encrypted business id),
'checkin_info': {
'0-0': (number of checkins from 00:00 to 01:00 on all Sundays),
'1-0': (number of checkins from 01:00 to 02:00 on all Sundays),
...
'14-4': (number of checkins from 14:00 to 15:00 on all Thursdays),
...
'23-6': (number of checkins from 23:00 to 00:00 on all Saturdays)
} # if there was no checkin for an hour-day block it will not be in the dict
}
"""
cid = peewee.PrimaryKeyField()
business_id = peewee.CharField()
sunday_count = peewee.IntegerField(default=0)
monday_count = peewee.IntegerField(default=0)
tuesday_count = peewee.IntegerField(default=0)
wednesday_count = peewee.IntegerField(default=0)
thursday_count = peewee.IntegerField(default=0)
friday_count = peewee.IntegerField(default=0)
saturday_count = peewee.IntegerField(default=0)
class Meta:
database = db
class Tip(peewee.Model):
"""
{
'type': 'tip',