xync-schema 0.6.40__tar.gz → 0.6.41__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.40
3
+ Version: 0.6.41
4
4
  Summary: XyncNet project database model schema
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: EULA
@@ -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(null=True)
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(null=True)
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 self.fiats._db_queryset().values("amount", "pmcur__cur__rate")
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
- computed = ["balance"]
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):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xync-schema
3
- Version: 0.6.40
3
+ Version: 0.6.41
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