xync-schema 0.6.33__tar.gz → 0.6.35__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xync-schema
3
- Version: 0.6.33
3
+ Version: 0.6.35
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
@@ -1,6 +1,7 @@
1
1
  from datetime import datetime
2
2
  from enum import IntEnum
3
3
  from tortoise import fields
4
+ from tortoise.queryset import QuerySet
4
5
  from x_auth.enums import Role
5
6
  from x_auth.models import Model
6
7
  from x_model.models import TsTrait, DatetimeSecField
@@ -178,6 +179,9 @@ class Ex(Model):
178
179
  table_description = "Exchanges"
179
180
  unique_together = (("name", "type_"),)
180
181
 
182
+ class PydanticMeta(Model.PydanticMeta):
183
+ include = "name", "logo"
184
+
181
185
 
182
186
  class Curex(Model):
183
187
  cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
@@ -281,21 +285,18 @@ class Agent(Model, TsTrait):
281
285
  unique_together = (("ex", "user"),)
282
286
 
283
287
  class PydanticMeta(Model.PydanticMeta):
288
+ # max_recursion = 3
289
+ include = "ex", "assets", "auth", "updated_at"
284
290
  computed = ["balance"]
285
291
 
286
- # class PydanticMetaListItem:
287
- # max_recursion = 1
288
- # backward_relations: bool = True
289
- # exclude = ("user",)
290
- # computed = ["balance"]
292
+ async def client(self):
293
+ import sys
291
294
 
292
- # async def client(self):
293
- # import sys
294
- # if isinstance(self.ex, QuerySet):
295
- # # noinspection PyTypeChecker
296
- # self.ex: Ex = await self.ex
297
- # client = sys.modules[f'xync_client.{self.ex.name}.p2p'].AgentClient
298
- # return client(self)
295
+ if isinstance(self.ex, QuerySet):
296
+ # noinspection PyTypeChecker
297
+ self.ex: Ex = await self.ex
298
+ client = sys.modules[f"xync_client.{self.ex.name}.p2p"].AgentClient
299
+ return client(self)
299
300
 
300
301
 
301
302
  class Adpm(Model):
@@ -365,32 +366,11 @@ class Pmcur(Model): # for fiat with no exs tie
365
366
 
366
367
  _name = {"pm__name", "cur__ticker"}
367
368
 
368
- # _sorts = ['-limits_count']
369
-
370
- # @classmethod
371
- # def pydListItem(cls, max_recursion: int = 1, backward_relations: bool = False, exclude: tuple[str] = (), include: tuple[str] = (), force: bool = False) -> type[PydanticModel]:
372
- # if not cls._pydListItem:
373
- # mo = PydanticMeta
374
- # mo.max_recursion = 1
375
- # mo.exclude_raw_fields = True # default: True
376
- # # mo.backward_relations = False # default: True
377
- # cls._pydListItem = pydantic_model_creator(cls, name=cls.__name__ + 'ListItem', meta_override=mo, exclude=('pmcurexs',))
378
- # return cls._pydListItem
379
-
380
- # @classmethod
381
- # def pageQuery(cls, sorts: list[str], limit: int = 1000, offset: int = 0, q: str = None, owner: bool = None, **kwargs) -> QuerySet:
382
- # query = super().pageQuery([], limit, offset, q)
383
- # if kwargs.pop('only_empty', None):
384
- # query = query.exclude(limits__not_isnull=True)
385
- # else:
386
- # query = query.annotate(limits_count=Count('limits')).order_by('-limits_count')
387
- # return query.filter(**kwargs)
388
-
389
369
  class Meta:
390
370
  table_description = "Payment methods - Currencies"
391
371
  unique_together = (("pm", "cur"),)
392
372
 
393
- class PydanticMeta:
373
+ class PydanticMeta(Model.PydanticMeta):
394
374
  exclude_raw_fields: bool = False
395
375
 
396
376
 
@@ -436,15 +416,16 @@ class Fiat(Model):
436
416
  exs: fields.ManyToManyRelation[Ex] = fields.ManyToManyField("models.Ex", through="fiatex", related_name="fiats")
437
417
  orders: fields.ReverseRelation["Order"]
438
418
 
439
- _name = {"pmcur__pm__name", "pmcur__cur__ticker", "amount"}
419
+ # _name = {"pmcur__pm__name", "pmcur__cur__ticker", "amount"}
440
420
 
441
421
  class Meta:
442
422
  table_description = "Currency accounts balance"
443
423
 
444
- # class PydanticMetaListItem:
445
- # max_recursion: int = 2
446
- # backward_relations = False
447
- # exclude = "user", "pmcur__exs"
424
+ class PydanticMeta(Model.PydanticMeta):
425
+ # max_recursion: int = 2
426
+ backward_relations = False
427
+ include = "id", "pmcur", "detail", "name", "amount"
428
+
448
429
  # # exclude_raw_fields = True
449
430
 
450
431
 
@@ -497,8 +478,8 @@ class Asset(Model):
497
478
  table_description = "Coin balance"
498
479
  unique_together = (("coin", "agent", "type_"),)
499
480
 
500
- # class PydanticMeta(Model.PydanticMeta):
501
- # exclude_raw_fields: bool = False
481
+ class PydanticMeta(Model.PydanticMeta):
482
+ max_recursion: int = 2 # default: 3
502
483
 
503
484
 
504
485
  class Order(Model, TsTrait):
@@ -11,6 +11,12 @@ class FiatUpd(BaseModel):
11
11
  class FiatNew(FiatUpd):
12
12
  cur_id: int
13
13
  pm_id: int
14
- user_id: int
14
+ detail: str
15
+ amount: float = 0
16
+
17
+
18
+ class Agent(BaseModel):
19
+ cur_id: int
20
+ pm_id: int
15
21
  detail: str
16
22
  amount: float = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xync-schema
3
- Version: 0.6.33
3
+ Version: 0.6.35
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
File without changes
File without changes
File without changes
File without changes
File without changes