try fix licenses

This commit is contained in:
user committed 2025-03-14 10:54:57 +03:00
1 parent 7d962d463b
commit 66da3541e7
3 files changed
+14 -10

No files matched your search

+7 -5
View File
@@ -3,7 +3,7 @@ from base64 import b64decode
from datetime import datetime, timedelta
from base58 import b58encode
from sqlalchemy import and_
from sqlalchemy import and_, or_
from tonsdk.boc import Cell
from tonsdk.utils import Address
@@ -74,12 +74,14 @@ async def license_index_loop(memory, platform_found: bool, seqno: int) -> [bool,
# Проверка кошельков пользователей на появление новых NFT, добавление их в базу как неопознанные
for user in session.query(User).filter(
User.last_use > datetime.now() - timedelta(minutes=10)
).all():
if not user.wallet_address(session):
User.last_use > datetime.now() - timedelta(hours=4)
).order_by(User.updated.asc()).all():
user_wallet_address = user.wallet_address(session)
if not user_wallet_address:
make_log("LicenseIndex", f"User {user.id} has no wallet address", level="info")
continue
make_log("LicenseIndex", f"User {user.id} has wallet address {user_wallet_address}", level="info")
last_updated_licenses = user.meta.get('last_updated_licenses')
must_skip = last_updated_licenses and (datetime.now() - datetime.fromisoformat(last_updated_licenses)) < timedelta(minutes=1)
make_log("LicenseIndex", f"User: {user.id}, last_updated_licenses: {last_updated_licenses}, must_skip: {must_skip}", level="info")
@@ -99,7 +101,7 @@ async def license_index_loop(memory, platform_found: bool, seqno: int) -> [bool,
UserContent.type.startswith('nft/'),
UserContent.updated < (datetime.now() - timedelta(minutes=60)),
)
).first()
).order_by(UserContent.updated.asc()).first()
if process_content:
make_log("LicenseIndex", f"Syncing content with blockchain: {process_content.id}", level="info")
try:
+3 -3
View File
@@ -157,7 +157,7 @@ async def main_fn(memory):
in_msg_blockchain_task.status = 'done'
in_msg_blockchain_task.transaction_hash = transaction_hash
in_msg_blockchain_task.transaction_lt = transaction_lt
await session.commit()
session.commit()
for blockchain_message in [transaction['in_msg']]:
try:
@@ -210,7 +210,7 @@ async def main_fn(memory):
# or sum([int("terminating vm with exit code 36" in e) for e in errors_list]) > 0:
make_log("TON_Daemon", f"Task {blockchain_task.id} done", level="DEBUG")
blockchain_task.status = 'done'
await session.commit()
session.commit()
continue
await asyncio.sleep(0.5)
@@ -266,7 +266,7 @@ async def main_fn(memory):
'sign_created': sign_created,
'signed_message': query_boc.hex(),
}
await session.commit()
session.commit()
make_log("TON", f"Created signed message for task {blockchain_task.id}" + '\n' + traceback.format_exc(), level="info")
except BaseException as e:
make_log("TON", f"Error processing task {blockchain_task.id}: {e}" + '\n' + traceback.format_exc(), level="error")