xync-db 0.3.1__tar.gz → 0.4.0__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.
Files changed (37) hide show
  1. {xync_db-0.3.1 → xync_db-0.4.0}/PKG-INFO +1 -1
  2. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/models/__init__.py +32 -0
  3. {xync_db-0.3.1 → xync_db-0.4.0}/.gitignore +0 -0
  4. {xync_db-0.3.1 → xync_db-0.4.0}/README.md +0 -0
  5. {xync_db-0.3.1 → xync_db-0.4.0}/pyproject.toml +0 -0
  6. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/__init__.py +0 -0
  7. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/config.py +0 -0
  8. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/enums.py +0 -0
  9. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/exceptions.py +0 -0
  10. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/graph.py +0 -0
  11. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/i18n.py +0 -0
  12. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/logo.png +0 -0
  13. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/CLAUDE.md +0 -0
  14. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/__init__.py +0 -0
  15. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0001_initial.py +0 -0
  16. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0002_triggers.py +0 -0
  17. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0003_files_seed.py +0 -0
  18. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0004_all_seed.py +0 -0
  19. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0005_credex_del.py +0 -0
  20. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/0006_credex_orphan.py +0 -0
  21. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/__init__.py +0 -0
  22. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/seed/__init__.py +0 -0
  23. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/seed/a_actor_seed.py +0 -0
  24. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/seed/a_tg_seed.py +0 -0
  25. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/seed/b_htx_seed.py +0 -0
  26. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/migrations/models/seed/xync_files.sql +0 -0
  27. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/models/CLAUDE.md +0 -0
  28. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/py.typed +0 -0
  29. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/shared.py +0 -0
  30. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/__init__.py +0 -0
  31. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/__init__.py +0 -0
  32. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/actor.py +0 -0
  33. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/ad.py +0 -0
  34. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/common.py +0 -0
  35. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/cred.py +0 -0
  36. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/order.py +0 -0
  37. {xync_db-0.3.1 → xync_db-0.4.0}/src/xync_db/typs/db/pm.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: xync-db
3
- Version: 0.3.1
3
+ Version: 0.4.0
4
4
  Summary: Xync DB schema: Tortoise ORM models, enums, pydantic DTOs.
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: LicenseRef-EULA
@@ -1000,6 +1000,20 @@ class Agent(Model, TsTrait):
1000
1000
  dct = {coin_id: round(amount * 10 ** -(s := scales[coin_id]), s) for coin_id, amount in dct.items()}
1001
1001
  return dct[coin_id] if coin_id else dct
1002
1002
 
1003
+ @classmethod
1004
+ async def confirm_trade(cls, agent_id: int, confirm: bool) -> None:
1005
+ """Ответ владельца на вопрос «включить торговлю?» (Notifier.trade_confirm, заданный при выходе
1006
+ агента в listen). Зовут из web-контроллера и бот-колбэка — единый эмиттер канала
1007
+ `agents_trade_confirm`, который резолвит ждущий 30с future в хендлере листенера api
1008
+ (handlers.agents.agents_trade_confirm). На `True` хендлер включает торговлю на бирже
1009
+ (acl.ads_switch(True)), иначе снимает listen-бит. Через pg_notify (как CredEx.orphan_del), чтобы
1010
+ и web-, и bot-зона не дублировали полезную нагрузку, а ответ попадал в единый листенер api —
1011
+ там живут и future, и agent-клиент."""
1012
+ await connections.get("default").execute_query(
1013
+ "SELECT pg_notify('agents_trade_confirm', jsonb_build_array($1::int, $2::bool)::varchar)",
1014
+ [agent_id, confirm],
1015
+ )
1016
+
1003
1017
  @classmethod
1004
1018
  async def upsert(
1005
1019
  cls, exid: int, host: str, auth: dict, exp: int, rname: str, nick: str, email: str
@@ -1302,6 +1316,24 @@ class MyAd(Model): # Road
1302
1316
  "ad__pair_side__pair__coin", "ad__pair_side__pair__cur", "ad__maker__ex"
1303
1317
  )
1304
1318
 
1319
+ @classmethod
1320
+ async def unshared_hot_ad_ids(cls, hex_ex_ids: list[int] = SHARE_HEX_EX_IDS) -> list[int]:
1321
+ """ad_id активных hot-объяв share-hex-бирж без MyAd.hex, чей мейкер-агент ОНЛАЙН (listen-бит,
1322
+ `status & 2` → статусы listen|race_listen). Их надо было зашарить (агент слушает), но hex нет —
1323
+ для старт-алерта. Объява без hex у НЕактивного агента (off/race, бит 2 снят) — норма (он не шарит),
1324
+ не включаем. Гонка (бит 1) для шеринга не нужна, поэтому условие `& 2`, а не `>=3` (hot_mads_query)."""
1325
+ return (
1326
+ await cls.filter(
1327
+ hex__isnull=True,
1328
+ ad__status=AdStatus.active,
1329
+ ad__maker__ex_id__in=hex_ex_ids,
1330
+ credexs__cred__ovr_pm_id=0,
1331
+ ad__maker__agent__status__in=[AgentStatus.listen, AgentStatus.race_listen], # listen-бит (& 2)
1332
+ )
1333
+ .distinct()
1334
+ .values_list("ad_id", flat=True)
1335
+ )
1336
+
1305
1337
  @classmethod
1306
1338
  async def upsert(
1307
1339
  cls,
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