class Pokestop(BaseModel): pokestop_id = CharField(primary_key=True, max_length=50) enabled = BooleanField() latitude = DoubleField() longitude = DoubleField() last_modified = DateTimeField(index=True) lure_expiration = DateTimeField(null=True, index=True) active_fort_modifier = CharField(max_length=50, null=True) class Meta: indexes = ((('latitude', 'longitude'), False), ) @staticmethod def get_stops(swLat, swLng, neLat, neLng): if swLat is None or swLng is None or neLat is None or neLng is None: query = (Pokestop.select().dicts()) else: query = (Pokestop.select().where( (Pokestop.latitude >= swLat) & (Pokestop.longitude >= swLng) & (Pokestop.latitude <= neLat) & (Pokestop.longitude <= neLng)).dicts()) pokestops = [] for p in query: if args.china: p['latitude'], p['longitude'] = \ transform_from_wgs_to_gcj(p['latitude'], p['longitude']) pokestops.append(p) return pokestops
class Pokemon(BaseModel): # We are base64 encoding the ids delivered by the api # because they are too big for sqlite to handle. encounter_id = UBigIntegerField(primary_key=True) spawnpoint_id = UBigIntegerField(index=True) pokemon_id = SmallIntegerField(index=True) latitude = DoubleField() longitude = DoubleField() disappear_time = DateTimeField(index=True) individual_attack = SmallIntegerField(null=True) individual_defense = SmallIntegerField(null=True) individual_stamina = SmallIntegerField(null=True) move_1 = SmallIntegerField(null=True) move_2 = SmallIntegerField(null=True) cp = SmallIntegerField(null=True) cp_multiplier = FloatField(null=True) weight = FloatField(null=True) height = FloatField(null=True) gender = SmallIntegerField(null=True) costume = SmallIntegerField(null=True) form = SmallIntegerField(null=True) weather_boosted_condition = SmallIntegerField(null=True) last_modified = DateTimeField(null=True, index=True, default=datetime.utcnow) class Meta: indexes = ((('latitude', 'longitude'), False), (('disappear_time', 'pokemon_id'), False))
class Paciente(BaseModel): id_paciente = AutoField(primary_key=True) id_endereco = ForeignKeyField(Endereco, column_name="id_endereco") peso = DoubleField() sexo = CharField() cpf = CharField(45) altura = DoubleField() telefone = CharField(45) nome = CharField(200) idade = IntegerField() email = CharField(200) atividade_fisica = CharField(200) foto = CharField(200) @staticmethod def autocomplete(): result = Paciente.select(Paciente.nome) pacientes = [model_to_dict(pac)["nome"] for pac in result] return json.dumps(pacientes) @staticmethod def buscar(nome): try: paciente = Paciente.select().where(Paciente.nome == nome).get() return paciente except Exception as e: return u"" + str(e)
class Actor(BaseModel): id = PrimaryKeyField() swid = IntegerField(unique=True, index=True) display_name = TextField(index=True, null=True) first_name = TextField(null=True) last_name = TextField(null=True) alt_names = TextField(null=True) nationality = TextField(null=True) birthdate = DateTimeField(null=True) position = TextField(null=True) height = DoubleField(null=True) weight = DoubleField(null=True) foot = TextField(null=True) def __str__(self): description = "{:<5} {:<7} | {:<15} | ".format("Actor", self.swid, self.nationality) description += "{:>17} | ".format(self.display_name) description += "{:<31} | ".format( str(self.first_name) + " " + str(self.last_name)) if self.height is not None and self.weight is not None: description += "{:>3.0f}cm | {:>2.0f}kg |".format( self.height, self.weight) if self.position is not None: description += "{:<10}".format(self.position) return description
class Target(TargetdbBase): catalogid = ForeignKeyField(column_name='catalogid', model=catalogdb.Catalog, field='catalogid') dec = DoubleField(null=True) epoch = FloatField(null=True) pk = AutoField() pmdec = FloatField(null=True) pmra = FloatField(null=True) ra = DoubleField(null=True) designs = ManyToManyField(Design, through_model=AssignmentDeferred, backref='targets') positioners = ManyToManyField(Positioner, through_model=AssignmentDeferred, backref='targets') instruments = ManyToManyField(Instrument, through_model=AssignmentDeferred, backref='targets') cadences = ManyToManyField(Cadence, through_model=CartonToTargetDeferred, backref='targets') parallax = FloatField(null=True) class Meta: table_name = 'target'
class Period(db.Model): product = ForeignKeyField(Product, null=False, verbose_name=u"商品") zj_user = ForeignKeyField(Users, null=True, verbose_name=u"中奖用户") number = IntegerField(default=100001, verbose_name=u"期号") total_count = IntegerField(default=0, verbose_name=u"总需人次") join_count = IntegerField(default=0, verbose_name=u"参与人次") kj_time = DateTimeField(null=True, verbose_name=u"开奖时间") kj_num = IntegerField(default=0, verbose_name=u"开奖号码") kj_ssc = DoubleField(default=0, verbose_name=u"时时彩号码") kj_count = DoubleField(default=0, verbose_name=u"时间总和") all_num = TextField(verbose_name=u"所有号码") end_time = DateTimeField(null=True, verbose_name=u"夺宝结束时间") status = IntegerField(default=0, verbose_name=u"状态", choices=types.period_status()) def __unicode__(self): return "%s %s%s" % (self.product.title, self.number, u"期") @staticmethod def get_period(pid): period = Period.get(id=pid) return period @staticmethod def get_hot_products(): query = Period.select().join(Product).where( Period.status == 0).order_by(Product.hits.desc()) return query @staticmethod def get_index_periods(cid): query = Period.select().join(Product).where( Product.category == cid, Period.status == 0).limit(8) return query @staticmethod def get_list_periods(cid, order='hot', page=1): if cid: query = Period.select().join(Product).where( Product.category == cid, Period.status == 0) else: query = Period.select().join(Product).where(Period.status == 0) if order == 'hot': query = query.order_by(Product.hits.desc()) elif order == 'left': query = query.order_by((Period.total_count - Period.join_count)) elif order == 'new': query = query.order_by(Product.created_datetime.desc()) elif order == 'price_up': query = query.order_by(Period.total_count) elif order == 'price_down': query = query.order_by(Period.total_count.desc()) return query.paginate(page, 9) @staticmethod def get_announced_list(): query = Period.select().where(Period.status == 1).order_by( Period.end_time.desc()) return query
class ScannedLocation(BaseModel): latitude = DoubleField() longitude = DoubleField() last_modified = DateTimeField(index=True) class Meta: primary_key = CompositeKey('latitude', 'longitude') @staticmethod def get_recent(swLat, swLng, neLat, neLng): query = (ScannedLocation .select() .where((ScannedLocation.last_modified >= (datetime.utcnow() - timedelta(minutes=15))) & (ScannedLocation.latitude >= swLat) & (ScannedLocation.longitude >= swLng) & (ScannedLocation.latitude <= neLat) & (ScannedLocation.longitude <= neLng)) .dicts()) scans = [] for s in query: scans.append(s) return scans
class ReservationService(BaseModel): reservation = ForeignKeyField(Reservation) service_id = IntegerField() # Without ForeignKeyField name = CharField() duration_m = DoubleField() price = DoubleField() description = TextField(null=True)
class Gym(BaseModel): UNCONTESTED = 0 TEAM_MYSTIC = 1 TEAM_VALOR = 2 TEAM_INSTINCT = 3 gym_id = CharField(primary_key=True, max_length=50) team_id = IntegerField() guard_pokemon_id = IntegerField() gym_points = IntegerField() enabled = BooleanField() latitude = DoubleField() longitude = DoubleField() last_modified = DateTimeField(index=True) class Meta: indexes = ((('latitude', 'longitude'), False), ) @staticmethod def get_gyms(swLat, swLng, neLat, neLng): if swLat is None or swLng is None or neLat is None or neLng is None: query = (Gym.select().dicts()) else: query = (Gym.select().where((Gym.latitude >= swLat) & (Gym.longitude >= swLng) & (Gym.latitude <= neLat) & (Gym.longitude <= neLng)).dicts()) gyms = [] for g in query: gyms.append(g) return gyms
class Events(BaseModel): pin = ForeignKeyField(Pins, backref='Events') title = CharField() description = TextField() time_start = DateTimeField(default=datetime.datetime.now) time_end = DateTimeField(default=datetime.datetime.now) lat = DoubleField() lng = DoubleField()
class KF_UEFA(_Model): class Meta: db_table = 'koeffs_UEFA' country = CharField(max_length=100, index=True) seventeen_eighteen = DoubleField() eighteen_nineteen = DoubleField() nineteen_twenty = DoubleField() total_score = DoubleField()
class PriceLog(BaseModel): class Meta: db_table = "price_logs" created = DateTimeField(default=peewee_datetime.datetime.now) symbol = TextField() max_price = DoubleField() min_price = DoubleField() drop_percent = DoubleField()
class Weather(BaseModel): s2_cell_id = Utf8mb4CharField(primary_key=True, max_length=50) latitude = DoubleField() longitude = DoubleField() cloud_level = SmallIntegerField(null=True, index=True, default=0) rain_level = SmallIntegerField(null=True, index=True, default=0) wind_level = SmallIntegerField(null=True, index=True, default=0) snow_level = SmallIntegerField(null=True, index=True, default=0) fog_level = SmallIntegerField(null=True, index=True, default=0) wind_direction = SmallIntegerField(null=True, index=True, default=0) gameplay_weather = SmallIntegerField(null=True, index=True, default=0) severity = SmallIntegerField(null=True, index=True, default=0) warn_weather = SmallIntegerField(null=True, index=True, default=0) world_time = SmallIntegerField(null=True, index=True, default=0) last_updated = DateTimeField(default=datetime.utcnow, null=True, index=True) @staticmethod def get_weathers(): query = Weather.select().dicts() weathers = [] for w in query: weathers.append(w) return weathers @staticmethod def get_weather_by_location(swLat, swLng, neLat, neLng, alert): # We can filter by the center of a cell, this deltas can expand # the viewport bounds # So cells with center outside the viewport, but close to it # can be rendered # otherwise edges of cells that intersects with viewport # won't be rendered lat_delta = 0.15 lng_delta = 0.4 if not alert: query = Weather.select().where( (Weather.latitude >= float(swLat) - lat_delta) & (Weather.longitude >= float(swLng) - lng_delta) & (Weather.latitude <= float(neLat) + lat_delta) & (Weather.longitude <= float(neLng) + lng_delta)).dicts() else: query = Weather.select().where( (Weather.latitude >= float(swLat) - lat_delta) & (Weather.longitude >= float(swLng) - lng_delta) & (Weather.latitude <= float(neLat) + lat_delta) & (Weather.longitude <= float(neLng) + lng_delta) & (Weather.severity.is_null(False))).dicts() weathers = [] for w in query: weathers.append(w) return weathers
class last_event(Model): #id_evento = BigAutoField() id_evento = DoubleField() uuid = CharField() timestamp = DateTimeField(default=datetime.datetime.now) total_consume = DoubleField() have_alert = BooleanField() class Meta: database = mysql_db
class Paper(BaseModel): id = TextField(primary_key=True, default=next_id) state = TextField(null=True) name = TextField() tag = TextField(null=True) cover = TextField(null=True) munber = IntegerField(null=True) total = IntegerField(null=True) finish_time = DoubleField(null=True) ctime = DoubleField(default=time.time)
class Service(BaseModel): service_id = AutoField() name = CharField() duration_m = DoubleField(default=0) price = DoubleField(default=0) description = TextField(null=True) created_date = DateTimeField(default=datetime.datetime.now) created_by = ForeignKeyField(User, backref='user') updated_date = DateTimeField(default=datetime.datetime.now) updated_by = ForeignKeyField(User, null=True, backref='user') business = ForeignKeyField(Business, backref='business')
class Pokemon(BaseModel): # We are base64 encoding the ids delivered by the api # because they are too big for sqlite to handle encounter_id = CharField(primary_key=True, max_length=50) spawnpoint_id = CharField() pokemon_id = IntegerField() latitude = DoubleField() longitude = DoubleField() disappear_time = DateTimeField() @classmethod def get_active(cls, swLat, swLng, neLat, neLng): if swLat is None or swLng is None or neLat is None or neLng is None: query = (Pokemon.select().where( Pokemon.disappear_time > datetime.utcnow()).dicts()) else: query = (Pokemon.select().where( (Pokemon.disappear_time > datetime.utcnow()) & (Pokemon.latitude >= swLat) & (Pokemon.longitude >= swLng) & (Pokemon.latitude <= neLat) & (Pokemon.longitude <= neLng)).dicts()) pokemons = [] for p in query: p['pokemon_name'] = get_pokemon_name(p['pokemon_id']) if args.china: p['latitude'], p['longitude'] = \ transform_from_wgs_to_gcj(p['latitude'], p['longitude']) pokemons.append(p) return pokemons @classmethod def get_active_by_id(cls, ids, swLat, swLng, neLat, neLng): if swLat is None or swLng is None or neLat is None or neLng is None: query = (Pokemon.select().where((Pokemon.pokemon_id << ids) & ( Pokemon.disappear_time > datetime.utcnow())).dicts()) else: query = (Pokemon.select().where( (Pokemon.pokemon_id << ids) & (Pokemon.disappear_time > datetime.utcnow()) & (Pokemon.latitude >= swLat) & (Pokemon.longitude >= swLng) & (Pokemon.latitude <= neLat) & (Pokemon.longitude <= neLng)).dicts()) pokemons = [] for p in query: p['pokemon_name'] = get_pokemon_name(p['pokemon_id']) if args.china: p['latitude'], p['longitude'] = \ transform_from_wgs_to_gcj(p['latitude'], p['longitude']) pokemons.append(p) return pokemons
class Posto(BaseModel): """ Classe representando uma instancia de um posto Attributes: nome = String - nome do Posto longitude e latitude = coordenadas da localizacao do posto no GPS """ nome = CharField(max_length=100) longitude = DoubleField(null=False) latitude = DoubleField(null=False) usuario = ForeignKeyField(rel_model=Usuario, related_name="postos")
class MetadataModel(Model): cloud_cover = FloatField() acquired = DateTimeField() north_lat = DoubleField() south_lat = DoubleField() west_lon = DoubleField() east_lon = DoubleField() class Meta: database = Database( "[bigquery-public-data:cloud_storage_geo_index.landsat_index]")
class Pins(BaseModel): user = ForeignKeyField(Users, backref='Pins') lat = DoubleField() lng = DoubleField() cleaned = BooleanField(default=False) created_at = DateTimeField(default=datetime.datetime.now) updated_at = DateTimeField(default=datetime.datetime.now) description = TextField() title = CharField() type = IntegerField() status = IntegerField(default=0)
class GatekeeperApprovedApps(BaseModel): """ Gatekeeper apps a user has allowed to run. """ path = TextField(help_text="Path of executable allowed to run") requirement = TextField(help_text="Code signing requirement language") ctime = DoubleField(help_text="Last change time") mtime = DoubleField(help_text="Last modification time") class Meta: table_name = "gatekeeper_approved_apps"
class TemperatureSensors(BaseModel): """ Machine\'s temperature sensors. """ key = TextField(help_text="The SMC key on OS X") # {'index': True} name = TextField(help_text="Name of temperature source") celsius = DoubleField(help_text="Temperature in Celsius") fahrenheit = DoubleField(help_text="Temperature in Fahrenheit") temperature_sensors = ForeignKeyField(SmcKeys, backref='key') class Meta: table_name = "temperature_sensors"
class Activity(Model): id = AutoField() name = CharField() type = CharField() distance = DoubleField() date = DateTimeField() estimated_time = IntegerField() # в минутах x = DoubleField() y = DoubleField() class Meta: database = database
class User(Model): id = IntegerField(primary_key=True) name = CharField() username = CharField() age = IntegerField() gender = CharField() city = CharField() x = DoubleField() y = DoubleField() class Meta: database = database
class Answers(BaseModel): """ Tabela z odpowiedziami dla danej jednostki ankietowej """ id = PrimaryKeyField() ankieta_id = ForeignKeyField(db_column='ankieta_id', model=Surveys, to_field='id') czynnik = TextField() ocena = IntegerField() pewnosc = DoubleField() waga = DoubleField(null=True) class Meta: db_table = 'odpowiedzi'
class XRate(Model): class Meta: database = db db_table = "rates" source = CharField() cc = CharField() ask = DoubleField() bid = DoubleField() updated = DateTimeField() def __str__(self): return f"{self.updated} - {self.source}: {self.cc} Ask (продажа): {self.ask} Bid (покупка): {self.bid}"
class Map(BaseModel): beatmap_id = IntegerField() enabled_mods = IntegerField() aim_pp = DoubleField(index=True) speed_pp = DoubleField(index=True) acc_pp = DoubleField(index=True) total_pp = DoubleField(index=True) farminess = IntegerField(index=True) class Meta: table_name = 'maps' db_table = 'maps' primary_key = CompositeKey('beatmap_id', 'enabled_mods')
class casa_info(Model): uuid = CharField() senha = CharField() nr_residentes = IntegerField() corrente_nominal = DoubleField() public_building = BooleanField() tensao_nominal = DoubleField() latitude = CharField() longitude = CharField() cidade = IntegerField() class Meta: database = mysql_db
class Avaliacao_Fisica(BaseModel): id_avaliacao = AutoField(primary_key=True) id_paciente = ForeignKeyField(Paciente, column_name="id_paciente", backref="avaliacao_fisica") porcentagem_gordura = DoubleField() metabolismo_basal = DoubleField() porcentagem_massa_muscular = DoubleField() altura = DoubleField() imc = DoubleField() porcentagem_massa_magra = DoubleField() pressao = DoubleField() objetivo = CharField(450) data = CharField() peso = DoubleField() observacoes = CharField(450) @staticmethod def listarAvaliacao(pagina=1): try: lista = Avaliacao_Fisica.select().order_by( Avaliacao_Fisica.id_paciente).paginate(pagina, 10) return lista except Exception, e: return e
class Pokestop(BaseModel): pokestop_id = Utf8mb4CharField(primary_key=True, max_length=50) enabled = BooleanField() latitude = DoubleField() longitude = DoubleField() last_modified = DateTimeField(index=True) lure_expiration = DateTimeField(null=True, index=True) active_fort_modifier = SmallIntegerField(null=True, index=True) last_updated = DateTimeField(null=True, index=True, default=datetime.utcnow) class Meta: indexes = ((('latitude', 'longitude'), False), )