xync-schema 0.6.25__tar.gz → 0.6.27__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.25 → xync_schema-0.6.27}/.gitignore +1 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/.pre-commit-config.yaml +1 -1
- {xync_schema-0.6.25/xync_schema.egg-info → xync_schema-0.6.27}/PKG-INFO +2 -3
- {xync_schema-0.6.25 → xync_schema-0.6.27}/makefile +4 -4
- {xync_schema-0.6.25 → xync_schema-0.6.27}/pyproject.toml +5 -2
- xync_schema-0.6.27/tests/test_db.py +29 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema/models.py +19 -48
- {xync_schema-0.6.25 → xync_schema-0.6.27/xync_schema.egg-info}/PKG-INFO +2 -3
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema.egg-info/SOURCES.txt +0 -1
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema.egg-info/requires.txt +1 -2
- xync_schema-0.6.25/requirements.dev.txt +0 -6
- xync_schema-0.6.25/tests/test_db.py +0 -21
- {xync_schema-0.6.25 → xync_schema-0.6.27}/.env.sample +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/README.md +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/setup.cfg +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/tests/__init__.py +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema/__init__.py +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.6.25 → xync_schema-0.6.27}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -22,7 +22,7 @@ repos:
|
|
|
22
22
|
- id: build
|
|
23
23
|
name: build
|
|
24
24
|
### build & upload package only for "main" branch push
|
|
25
|
-
entry: bash -c 'echo $PRE_COMMIT_LOCAL_BRANCH | grep /master && make
|
|
25
|
+
entry: bash -c 'echo $PRE_COMMIT_LOCAL_BRANCH | grep /master && make twine || echo 0'
|
|
26
26
|
language: system
|
|
27
27
|
pass_filenames: false
|
|
28
28
|
verbose: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xync-schema
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.27
|
|
4
4
|
Summary: XyncNet project database model schema
|
|
5
5
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: EULA
|
|
@@ -8,8 +8,7 @@ Project-URL: Homepage, https://gitlab.com/xync/back/schema
|
|
|
8
8
|
Project-URL: Repository, https://gitlab.com/xync/back/schema
|
|
9
9
|
Requires-Python: >=3.11
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
-
Requires-Dist:
|
|
12
|
-
Requires-Dist: aiogram
|
|
11
|
+
Requires-Dist: xtg-auth
|
|
13
12
|
Provides-Extra: dev
|
|
14
13
|
Requires-Dist: pytest; extra == "dev"
|
|
15
14
|
Requires-Dist: build; extra == "dev"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
include .env
|
|
1
2
|
PACKAGE := xync_schema
|
|
2
|
-
|
|
3
|
-
VPYTHON := . $(VENV)/bin/activate && python
|
|
3
|
+
VPYTHON := $(VENV)/bin/python
|
|
4
4
|
|
|
5
5
|
.PHONY: all install pre-commit test clean build twine patch
|
|
6
6
|
|
|
@@ -19,8 +19,8 @@ clean: .pytest_cache dist $(PACKAGE).egg-info
|
|
|
19
19
|
rm -rf .pytest_cache dist/* $(PACKAGE).egg-info $(PACKAGE)/__pycache__ dist/__pycache__
|
|
20
20
|
|
|
21
21
|
build:
|
|
22
|
-
$(VPYTHON) -m build
|
|
23
|
-
twine: dist
|
|
22
|
+
$(VPYTHON) -m build
|
|
23
|
+
twine: build dist
|
|
24
24
|
$(VPYTHON) -m twine upload dist/* --skip-existing
|
|
25
25
|
|
|
26
26
|
patch:
|
|
@@ -5,8 +5,7 @@ authors = [
|
|
|
5
5
|
{name = "Mike Artemiev", email = "mixartemev@gmail.com"},
|
|
6
6
|
]
|
|
7
7
|
dependencies = [
|
|
8
|
-
"
|
|
9
|
-
"aiogram"
|
|
8
|
+
"xtg-auth"
|
|
10
9
|
]
|
|
11
10
|
description = "XyncNet project database model schema"
|
|
12
11
|
readme = "README.md"
|
|
@@ -32,5 +31,9 @@ dev = [
|
|
|
32
31
|
"setuptools_scm",
|
|
33
32
|
]
|
|
34
33
|
|
|
34
|
+
[tool.pytest.ini_options]
|
|
35
|
+
asyncio_mode = "auto"
|
|
36
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
37
|
+
|
|
35
38
|
[tool.ruff]
|
|
36
39
|
line-length = 120
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from os import getenv as env
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from dotenv import load_dotenv
|
|
5
|
+
from tortoise import connections
|
|
6
|
+
from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
7
|
+
from x_model import init_db
|
|
8
|
+
|
|
9
|
+
from xync_schema import models
|
|
10
|
+
from xync_schema.models import Cur
|
|
11
|
+
|
|
12
|
+
load_dotenv()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture
|
|
16
|
+
async def dbc() -> AsyncpgDBClient:
|
|
17
|
+
await init_db(env("DB_URL"), models, True)
|
|
18
|
+
cn: AsyncpgDBClient = connections.get("default")
|
|
19
|
+
yield cn
|
|
20
|
+
await cn.close()
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
async def test_init_db(dbc):
|
|
24
|
+
assert isinstance(dbc, AsyncpgDBClient), "DB corrupt"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
async def test_models(dbc):
|
|
28
|
+
c = await Cur.all()
|
|
29
|
+
assert isinstance(c, list), "No currencies"
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from enum import IntEnum
|
|
3
3
|
from tortoise import fields
|
|
4
|
-
from
|
|
4
|
+
from x_model.model import Model, TsTrait, DatetimeSecField
|
|
5
|
+
from tg_auth.models import UserRefTrait, UserInfoTrait, User as BaseUser, UserStatus
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class AdvStatus(IntEnum):
|
|
@@ -63,20 +64,6 @@ class TaskType(IntEnum):
|
|
|
63
64
|
invite_approve = 1
|
|
64
65
|
|
|
65
66
|
|
|
66
|
-
class UserStatus(IntEnum):
|
|
67
|
-
CREATOR = 5
|
|
68
|
-
ADMINISTRATOR = 4
|
|
69
|
-
MEMBER = 3
|
|
70
|
-
RESTRICTED = 2
|
|
71
|
-
LEFT = 1
|
|
72
|
-
KICKED = 0
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
class Lang(IntEnum):
|
|
76
|
-
ru = 1
|
|
77
|
-
en = 2
|
|
78
|
-
|
|
79
|
-
|
|
80
67
|
class ExAction(IntEnum):
|
|
81
68
|
"""Public"""
|
|
82
69
|
|
|
@@ -119,7 +106,7 @@ class ExAction(IntEnum):
|
|
|
119
106
|
|
|
120
107
|
|
|
121
108
|
class Country(Model):
|
|
122
|
-
id = fields.SmallIntField(
|
|
109
|
+
id = fields.SmallIntField(True)
|
|
123
110
|
code: int | None = fields.IntField(null=True)
|
|
124
111
|
short: str | None = fields.CharField(3, unique=True, null=True)
|
|
125
112
|
name: str | None = fields.CharField(63, unique=True, null=True)
|
|
@@ -131,7 +118,7 @@ class Country(Model):
|
|
|
131
118
|
|
|
132
119
|
|
|
133
120
|
class Cur(Model):
|
|
134
|
-
id = fields.SmallIntField(
|
|
121
|
+
id = fields.SmallIntField(True)
|
|
135
122
|
ticker: str = fields.CharField(3, unique=True)
|
|
136
123
|
rate: float | None = fields.FloatField(null=True)
|
|
137
124
|
country: str | None = fields.CharField(63, null=True)
|
|
@@ -149,7 +136,7 @@ class Cur(Model):
|
|
|
149
136
|
|
|
150
137
|
|
|
151
138
|
class Coin(Model):
|
|
152
|
-
id: int = fields.SmallIntField(
|
|
139
|
+
id: int = fields.SmallIntField(True)
|
|
153
140
|
ticker: str = fields.CharField(15, unique=True)
|
|
154
141
|
rate: float | None = fields.FloatField(null=True)
|
|
155
142
|
is_fiat: bool = fields.BooleanField(default=False)
|
|
@@ -172,7 +159,7 @@ class Coin(Model):
|
|
|
172
159
|
|
|
173
160
|
|
|
174
161
|
class Ex(Model):
|
|
175
|
-
id: int = fields.SmallIntField(
|
|
162
|
+
id: int = fields.SmallIntField(True)
|
|
176
163
|
name: str = fields.CharField(31)
|
|
177
164
|
host: str | None = fields.CharField(31, null=True)
|
|
178
165
|
url: str | None = fields.CharField(63, null=True)
|
|
@@ -208,8 +195,8 @@ class Curex(Model):
|
|
|
208
195
|
_name = {"cur__ticker", "ex__name"}
|
|
209
196
|
|
|
210
197
|
|
|
211
|
-
class Pair(
|
|
212
|
-
id = fields.SmallIntField(
|
|
198
|
+
class Pair(Model, TsTrait):
|
|
199
|
+
id = fields.SmallIntField(True)
|
|
213
200
|
coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin", related_name="pairs")
|
|
214
201
|
cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur", related_name="pairs")
|
|
215
202
|
fee: float = fields.FloatField()
|
|
@@ -228,7 +215,7 @@ class Pair(TsModel):
|
|
|
228
215
|
|
|
229
216
|
|
|
230
217
|
class Direction(Model):
|
|
231
|
-
id = fields.SmallIntField(
|
|
218
|
+
id = fields.SmallIntField(True)
|
|
232
219
|
pair: fields.ForeignKeyRelation[Pair] = fields.ForeignKeyField("models.Pair", related_name="directions")
|
|
233
220
|
sell: bool = fields.BooleanField()
|
|
234
221
|
total: int = fields.IntField()
|
|
@@ -245,20 +232,9 @@ class Direction(Model):
|
|
|
245
232
|
return f"{self.pair.coin.ticker}/{self.pair.cur.ticker} {'SELL' if self.sell else 'BUY'}"
|
|
246
233
|
|
|
247
234
|
|
|
248
|
-
class User(BaseUser): # tg user
|
|
249
|
-
id: int = fields.BigIntField(True)
|
|
250
|
-
status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.RESTRICTED)
|
|
251
|
-
username: str | None = fields.CharField(95, unique=True, null=True)
|
|
235
|
+
class User(BaseUser, UserRefTrait, UserInfoTrait): # tg user
|
|
252
236
|
chat_status: UserStatus = fields.IntEnumField(UserStatus, default=UserStatus.LEFT)
|
|
253
237
|
in_channel: bool | None = fields.BooleanField(default=False, null=True)
|
|
254
|
-
first_name: str | None = fields.CharField(95, null=True)
|
|
255
|
-
last_name: str | None = fields.CharField(95, null=True)
|
|
256
|
-
pic: str | None = fields.CharField(95, null=True)
|
|
257
|
-
lang: Lang | None = fields.IntEnumField(Lang, default=Lang.ru, null=True)
|
|
258
|
-
ref: fields.ForeignKeyNullableRelation["User"] = fields.ForeignKeyField(
|
|
259
|
-
"models.User", related_name="proteges", null=True
|
|
260
|
-
)
|
|
261
|
-
ref_id: int | None
|
|
262
238
|
|
|
263
239
|
agents: fields.BackwardFKRelation["Agent"]
|
|
264
240
|
fiats: fields.BackwardFKRelation["Fiat"]
|
|
@@ -271,13 +247,8 @@ class User(BaseUser): # tg user
|
|
|
271
247
|
borrows: fields.BackwardFKRelation["Credit"]
|
|
272
248
|
investments: fields.BackwardFKRelation["Investment"]
|
|
273
249
|
|
|
274
|
-
_icon = "user"
|
|
275
250
|
|
|
276
|
-
|
|
277
|
-
table_description = "Users"
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
class Agent(TsModel):
|
|
251
|
+
class Agent(Model, TsTrait):
|
|
281
252
|
id: int
|
|
282
253
|
ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", related_name="agents")
|
|
283
254
|
# ex_id: int
|
|
@@ -322,8 +293,8 @@ class Adpm(Model):
|
|
|
322
293
|
table_description = "P2P Advertisements - Payment methods"
|
|
323
294
|
|
|
324
295
|
|
|
325
|
-
class Ad(
|
|
326
|
-
id: int = fields.BigIntField(
|
|
296
|
+
class Ad(Model, TsTrait):
|
|
297
|
+
id: int = fields.BigIntField(True)
|
|
327
298
|
direction: fields.ForeignKeyRelation[Direction] = fields.ForeignKeyField("models.Direction", related_name="ads")
|
|
328
299
|
price: float = fields.FloatField()
|
|
329
300
|
pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="adpm") # only root pms
|
|
@@ -526,8 +497,8 @@ class Asset(Model):
|
|
|
526
497
|
exclude_raw_fields: bool = False
|
|
527
498
|
|
|
528
499
|
|
|
529
|
-
class Order(
|
|
530
|
-
id: int = fields.BigIntField(
|
|
500
|
+
class Order(Model, TsTrait):
|
|
501
|
+
id: int = fields.BigIntField(True)
|
|
531
502
|
ad: fields.ForeignKeyRelation[Ad] = fields.ForeignKeyField("models.Ad", related_name="ads")
|
|
532
503
|
ad_id: int
|
|
533
504
|
amount: float = fields.FloatField()
|
|
@@ -551,7 +522,7 @@ class Order(TsModel):
|
|
|
551
522
|
table_description = "P2P Orders"
|
|
552
523
|
|
|
553
524
|
|
|
554
|
-
class Dep(
|
|
525
|
+
class Dep(Model, TsTrait):
|
|
555
526
|
pid: str = fields.CharField(31) # product_id
|
|
556
527
|
apr: float = fields.FloatField()
|
|
557
528
|
fee: float | None = fields.FloatField(null=True)
|
|
@@ -589,7 +560,7 @@ class Dep(TsModel):
|
|
|
589
560
|
unique_together = (("pid", "type", "ex"),)
|
|
590
561
|
|
|
591
562
|
|
|
592
|
-
class Investment(
|
|
563
|
+
class Investment(Model, TsTrait):
|
|
593
564
|
dep: fields.ForeignKeyRelation[Dep] = fields.ForeignKeyField("models.Dep", related_name="investments")
|
|
594
565
|
dep_id: int
|
|
595
566
|
amount: float = fields.FloatField()
|
|
@@ -641,7 +612,7 @@ class Vpn(Model):
|
|
|
641
612
|
table_description = "VPNs"
|
|
642
613
|
|
|
643
614
|
|
|
644
|
-
class Invite(
|
|
615
|
+
class Invite(Model, TsTrait):
|
|
645
616
|
ref: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="invite_approvals")
|
|
646
617
|
ref_id: int
|
|
647
618
|
protege: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="invite_requests")
|
|
@@ -658,7 +629,7 @@ class Invite(TsModel):
|
|
|
658
629
|
table_description = "Invites"
|
|
659
630
|
|
|
660
631
|
|
|
661
|
-
class Credit(
|
|
632
|
+
class Credit(Model, TsTrait):
|
|
662
633
|
lender: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="lends")
|
|
663
634
|
lender_id: int
|
|
664
635
|
borrower: fields.ForeignKeyRelation[User] = fields.ForeignKeyField("models.User", related_name="borrows")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xync-schema
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.27
|
|
4
4
|
Summary: XyncNet project database model schema
|
|
5
5
|
Author-email: Mike Artemiev <mixartemev@gmail.com>
|
|
6
6
|
License: EULA
|
|
@@ -8,8 +8,7 @@ Project-URL: Homepage, https://gitlab.com/xync/back/schema
|
|
|
8
8
|
Project-URL: Repository, https://gitlab.com/xync/back/schema
|
|
9
9
|
Requires-Python: >=3.11
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
|
-
Requires-Dist:
|
|
12
|
-
Requires-Dist: aiogram
|
|
11
|
+
Requires-Dist: xtg-auth
|
|
13
12
|
Provides-Extra: dev
|
|
14
13
|
Requires-Dist: pytest; extra == "dev"
|
|
15
14
|
Requires-Dist: build; extra == "dev"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
from asyncio import run
|
|
2
|
-
from os import getenv as env
|
|
3
|
-
from dotenv import load_dotenv
|
|
4
|
-
from tortoise_api_model import init_db
|
|
5
|
-
from tortoise.backends.asyncpg import AsyncpgDBClient
|
|
6
|
-
|
|
7
|
-
from xync_schema import models
|
|
8
|
-
from xync_schema.models import Cur
|
|
9
|
-
|
|
10
|
-
load_dotenv()
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def test_init_db():
|
|
14
|
-
res = run(init_db(env('DB_URL'), models))
|
|
15
|
-
assert isinstance(res, AsyncpgDBClient), "DB corrupt"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# def test_models():
|
|
19
|
-
# test_init_db()
|
|
20
|
-
# c = Cur.all()
|
|
21
|
-
# assert c.model, "DB corrupt"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|