xync-schema 0.6.40__tar.gz → 0.6.42__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.
- {xync_schema-0.6.40/xync_schema.egg-info → xync_schema-0.6.42}/PKG-INFO +1 -1
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema/enums.py +1 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema/models.py +9 -7
- {xync_schema-0.6.40 → xync_schema-0.6.42/xync_schema.egg-info}/PKG-INFO +1 -1
- {xync_schema-0.6.40 → xync_schema-0.6.42}/.env.sample +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/.gitignore +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/README.md +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/makefile +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/pyproject.toml +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/setup.cfg +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/tests/__init__.py +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/tests/test_db.py +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema/pydantic.py +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema.egg-info/SOURCES.txt +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.6.40 → xync_schema-0.6.42}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -23,7 +23,7 @@ from xync_schema.enums import ExType, AdStatus, AssetType, OrderStatus, ExAction
|
|
|
23
23
|
class Cur(Model):
|
|
24
24
|
id = fields.SmallIntField(True)
|
|
25
25
|
ticker: str = fields.CharField(3, unique=True)
|
|
26
|
-
rate: float | None = fields.FloatField(
|
|
26
|
+
rate: float | None = fields.FloatField(default=0)
|
|
27
27
|
# country: str | None = fields.CharField(63, null=True)
|
|
28
28
|
|
|
29
29
|
pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="pmcur")
|
|
@@ -40,7 +40,7 @@ class Cur(Model):
|
|
|
40
40
|
class Coin(Model):
|
|
41
41
|
id: int = fields.SmallIntField(True)
|
|
42
42
|
ticker: str = fields.CharField(15, unique=True)
|
|
43
|
-
rate: float | None = fields.FloatField(
|
|
43
|
+
rate: float | None = fields.FloatField(default=0)
|
|
44
44
|
is_fiat: bool = fields.BooleanField(default=False)
|
|
45
45
|
exs: fields.ManyToManyRelation["Ex"] = fields.ManyToManyField("models.Ex", through="coinex")
|
|
46
46
|
|
|
@@ -167,17 +167,19 @@ class User(Model, TsTrait):
|
|
|
167
167
|
return sum(asset["free"] * asset["coin__rate"] for asset in assets)
|
|
168
168
|
|
|
169
169
|
async def fiats_sum(self):
|
|
170
|
-
fiats = await
|
|
170
|
+
fiats = await Fiat.filter(user=self).values("amount", "pmcur__cur__rate")
|
|
171
171
|
return sum(fiat["amount"] * fiat["pmcur__cur__rate"] for fiat in fiats)
|
|
172
172
|
|
|
173
|
-
async def balance(self):
|
|
173
|
+
async def balance(self) -> float:
|
|
174
174
|
return await self.free_assets() + await self.fiats_sum()
|
|
175
175
|
|
|
176
176
|
def get_auth(self) -> AuthUser:
|
|
177
177
|
return AuthUser.model_validate(self, from_attributes=True)
|
|
178
178
|
|
|
179
|
-
class PydanticMeta(Model.PydanticMeta):
|
|
180
|
-
|
|
179
|
+
# class PydanticMeta(Model.PydanticMeta):
|
|
180
|
+
# max_recursion = 0
|
|
181
|
+
# include = "role", "status"
|
|
182
|
+
# computed = ["balance"]
|
|
181
183
|
|
|
182
184
|
|
|
183
185
|
class Agent(Model, TsTrait):
|
|
@@ -185,7 +187,7 @@ class Agent(Model, TsTrait):
|
|
|
185
187
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="agents")
|
|
186
188
|
auth: dict[str, str] = fields.JSONField(null=True)
|
|
187
189
|
user: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="agents")
|
|
188
|
-
|
|
190
|
+
user_id: int
|
|
189
191
|
assets: fields.ReverseRelation["Asset"]
|
|
190
192
|
orders: fields.ReverseRelation["Order"]
|
|
191
193
|
ads: fields.ReverseRelation["Ad"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|