xync-schema 0.6.24__py3-none-any.whl → 0.6.25.dev3__py3-none-any.whl
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.
- xync_schema/models.py +18 -2
- {xync_schema-0.6.24.dist-info → xync_schema-0.6.25.dev3.dist-info}/METADATA +1 -1
- xync_schema-0.6.25.dev3.dist-info/RECORD +6 -0
- xync_schema-0.6.24.dist-info/RECORD +0 -6
- {xync_schema-0.6.24.dist-info → xync_schema-0.6.25.dev3.dist-info}/WHEEL +0 -0
- {xync_schema-0.6.24.dist-info → xync_schema-0.6.25.dev3.dist-info}/top_level.txt +0 -0
xync_schema/models.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from enum import IntEnum
|
|
3
|
+
|
|
4
|
+
from pydantic import create_model
|
|
3
5
|
from tortoise import fields
|
|
6
|
+
from tortoise.contrib.pydantic import PydanticModel
|
|
4
7
|
from tortoise_api_model import Model, TsModel, DatetimeSecField, User as BaseUser
|
|
5
8
|
|
|
6
9
|
|
|
@@ -294,18 +297,31 @@ class Agent(TsModel):
|
|
|
294
297
|
def repr(self):
|
|
295
298
|
return f"{self.ex.name}-{self.user.username}"
|
|
296
299
|
|
|
300
|
+
@property
|
|
297
301
|
def balance(self) -> float:
|
|
298
302
|
return sum(asset.free * (asset.coin.rate or 0) for asset in self.assets)
|
|
299
303
|
|
|
304
|
+
@classmethod
|
|
305
|
+
def pydListItem(cls) -> type[PydanticModel]:
|
|
306
|
+
return create_model(
|
|
307
|
+
cls.__name__ + "ListItem",
|
|
308
|
+
balance=(int, 0),
|
|
309
|
+
__base__=super().pydListItem(),
|
|
310
|
+
)
|
|
311
|
+
|
|
300
312
|
class Meta:
|
|
301
313
|
table_description = "Agents"
|
|
302
314
|
unique_together = (("ex", "user"),)
|
|
303
315
|
|
|
316
|
+
class PydanticMeta:
|
|
317
|
+
computed = ["balance"]
|
|
318
|
+
|
|
304
319
|
class PydanticMetaListItem:
|
|
305
320
|
max_recursion = 1
|
|
306
321
|
backward_relations: bool = True
|
|
307
|
-
exclude =
|
|
308
|
-
|
|
322
|
+
exclude = "user",
|
|
323
|
+
# include = "balance",
|
|
324
|
+
# computed = ["balance"]
|
|
309
325
|
|
|
310
326
|
|
|
311
327
|
class Adpm(Model):
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
xync_schema/models.py,sha256=sfg4ftJ5gf2P96ZsPl6Vn9fEcT_1bGIFF0yb77QdUWg,24730
|
|
3
|
+
xync_schema-0.6.25.dev3.dist-info/METADATA,sha256=uppTgZLst_v8RIo068fhCFL_2MyptPe5Z8UGAi6bXJk,1171
|
|
4
|
+
xync_schema-0.6.25.dev3.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
5
|
+
xync_schema-0.6.25.dev3.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
|
|
6
|
+
xync_schema-0.6.25.dev3.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
xync_schema/models.py,sha256=-fJMSLDmmRxYkF_RBQvFN-SsIaYAyFSoptbkFYskH6o,24323
|
|
3
|
-
xync_schema-0.6.24.dist-info/METADATA,sha256=cFW9d923YCZtAaQauAZAUcaWXHOlTCUT5EHT7ACeZPQ,1166
|
|
4
|
-
xync_schema-0.6.24.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
5
|
-
xync_schema-0.6.24.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
|
|
6
|
-
xync_schema-0.6.24.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|