This commit is contained in:
parent
774a5ee596
commit
325927739e
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -149,4 +149,4 @@ dev-server.pid
|
||||||
backups/
|
backups/
|
||||||
poetry.lock
|
poetry.lock
|
||||||
.ruff_cache
|
.ruff_cache
|
||||||
dev-server.pid
|
.jj
|
||||||
|
|
|
@ -159,7 +159,7 @@ def topic_follow(follower_id, slug):
|
||||||
topic = session.query(Topic).where(Topic.slug == slug).one()
|
topic = session.query(Topic).where(Topic.slug == slug).one()
|
||||||
_following = TopicFollower(topic=topic.id, follower=follower_id)
|
_following = TopicFollower(topic=topic.id, follower=follower_id)
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception as _exc:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,9 @@ async def check_auth(req) -> str | None:
|
||||||
}
|
}
|
||||||
|
|
||||||
gql = {
|
gql = {
|
||||||
'query': f'query {operation}($params: ValidateJWTTokenInput!) {{ {query_name}(params: $params) {{ is_valid claims }} }}',
|
'query': f'query {operation}($params: ValidateJWTTokenInput!) {{' +
|
||||||
|
f'{query_name}(params: $params) {{ is_valid claims }} ' +
|
||||||
|
'}',
|
||||||
'variables': variables,
|
'variables': variables,
|
||||||
'operationName': operation,
|
'operationName': operation,
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ logger = logging.getLogger('\t[services.search]\t')
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
ELASTIC_HOST = (
|
ELASTIC_HOST = (
|
||||||
os.environ.get('ELASTIC_HOST', '').replace('https://', '').replace('http://', '')
|
os.environ.get('ELASTIC_HOST', '').replace('https://', '')
|
||||||
)
|
)
|
||||||
ELASTIC_USER = os.environ.get('ELASTIC_USER', '')
|
ELASTIC_USER = os.environ.get('ELASTIC_USER', '')
|
||||||
ELASTIC_PASSWORD = os.environ.get('ELASTIC_PASSWORD', '')
|
ELASTIC_PASSWORD = os.environ.get('ELASTIC_PASSWORD', '')
|
||||||
|
@ -99,8 +99,8 @@ class SearchService:
|
||||||
self.client = None
|
self.client = None
|
||||||
|
|
||||||
def info(self):
|
def info(self):
|
||||||
if self.client:
|
if isinstance(self.client, OpenSearch):
|
||||||
logger.info(f' Поиск подключен: {self.client.host}')
|
logger.info(f' Поиск подключен: {self.client.info()}')
|
||||||
else:
|
else:
|
||||||
logger.info(' * Задайте переменные среды для подключения к серверу поиска')
|
logger.info(' * Задайте переменные среды для подключения к серверу поиска')
|
||||||
|
|
||||||
|
@ -119,8 +119,6 @@ class SearchService:
|
||||||
)
|
)
|
||||||
self.client.indices.close(index=self.index_name)
|
self.client.indices.close(index=self.index_name)
|
||||||
self.client.indices.open(index=self.index_name)
|
self.client.indices.open(index=self.index_name)
|
||||||
except Exception as _exc: # noqa: S110
|
|
||||||
pass
|
|
||||||
finally:
|
finally:
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -197,7 +197,7 @@ class ViewedStorage:
|
||||||
try:
|
try:
|
||||||
await self.update_pages()
|
await self.update_pages()
|
||||||
failed = 0
|
failed = 0
|
||||||
except Exception:
|
except Exception as _exc:
|
||||||
failed += 1
|
failed += 1
|
||||||
logger.info(' - Обновление не удалось #%d, ожидание 10 секунд' % failed)
|
logger.info(' - Обновление не удалось #%d, ожидание 10 секунд' % failed)
|
||||||
if failed > 3:
|
if failed > 3:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user