fix: key management in admin menu / fixed synchronization
This commit is contained in:
@@ -185,3 +185,13 @@ async def mark_key_as_unfrozen(
|
||||
),
|
||||
{"expiry": new_expiry_time, "tg_id": tg_id, "client_id": client_id},
|
||||
)
|
||||
|
||||
|
||||
async def update_key_tariff(session: AsyncSession, client_id: str, tariff_id: int):
|
||||
await session.execute(
|
||||
update(Key)
|
||||
.where(Key.client_id == client_id)
|
||||
.values(tariff_id=tariff_id)
|
||||
)
|
||||
await session.commit()
|
||||
logger.info(f"Тариф ключа {client_id} обновлён на {tariff_id}")
|
||||
|
||||
@@ -45,6 +45,15 @@ async def get_tariffs_for_cluster(session: AsyncSession, cluster_name: str):
|
||||
.limit(1)
|
||||
)
|
||||
row = server_row.first()
|
||||
|
||||
if not row:
|
||||
server_row = await session.execute(
|
||||
select(Server.tariff_group)
|
||||
.where(Server.server_name == cluster_name)
|
||||
.limit(1)
|
||||
)
|
||||
row = server_row.first()
|
||||
|
||||
if not row or not row[0]:
|
||||
return []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user