diff --git a/.gitea/workflows/main.yml b/.gitea/workflows/main.yml index 6109fd26..25ee8bd7 100644 --- a/.gitea/workflows/main.yml +++ b/.gitea/workflows/main.yml @@ -1,8 +1,5 @@ name: 'Deploy to core' -on: - push: - branches: - - main +on: [push] jobs: deploy: @@ -24,8 +21,7 @@ jobs: - name: Push to dokku uses: dokku/github-action@master with: - branch: 'main' + branch: 'feature/core' git_remote_url: 'ssh://dokku@v2.discours.io:22/core' ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }} - git_push_flags: '--force' - + git_push_flags: '--force' \ No newline at end of file diff --git a/main.py b/main.py index df42d056..3771d5fe 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import os from importlib import import_module from os.path import exists +import sentry_sdk from ariadne import load_schema_from_path, make_executable_schema from ariadne.asgi import GraphQL from sentry_sdk.integrations.aiohttp import AioHttpIntegration @@ -26,7 +27,8 @@ schema = make_executable_schema(load_schema_from_path('schemas/core.graphql'), r async def start_up(): print(f'[main] starting in {MODE} mode') - await redis.connect() + with sentry_sdk.start_transaction(op='task', name='Redis Connection'): + await redis.connect() # start viewed service await ViewedStorage.init() @@ -40,8 +42,6 @@ async def start_up(): if MODE == 'production': # sentry monitoring try: - import sentry_sdk - sentry_sdk.init( SENTRY_DSN, enable_tracing=True, diff --git a/pyproject.toml b/pyproject.toml index 46e2d6f9..90c5f1c1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ python = "^3.12" SQLAlchemy = "^2.0.22" psycopg2-binary = "^2.9.9" redis = {extras = ["hiredis"], version = "^5.0.1"} -sentry-sdk = "^1.39.1" +sentry-sdk = "^1.4.1" starlette = "^0.36.1" gql = "^3.4.1" ariadne = "^0.21" diff --git a/resolvers/reader.py b/resolvers/reader.py index 92f3be8c..f92d07b7 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -4,7 +4,6 @@ from sqlalchemy.sql.expression import and_, asc, case, desc, func, nulls_last, s from starlette.exceptions import HTTPException from orm.author import Author, AuthorFollower -from orm.community import Community from orm.reaction import Reaction, ReactionKind from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility from orm.topic import Topic, TopicFollower @@ -316,12 +315,7 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0): .options( joinedload(Shout.authors), joinedload(Shout.topics), - joinedload(Shout.communities), ) - .select_from(Shout) - .join(Author, Shout.authors) # Ensure this join is not duplicated - .join(Topic, Shout.topics) # Ensure this join is not duplicated - .join(Community, Shout.communities) # Ensure this join is not duplicated .where(and_(Shout.deleted_at.is_(None), Shout.slug.in_(results_dict.keys()))) ) diff --git a/server.py b/server.py index d4067400..1301ba52 100644 --- a/server.py +++ b/server.py @@ -7,11 +7,11 @@ if __name__ == '__main__': granian_instance = Granian( 'main:app', - address='0.0.0.0', # noqa S104 + address='0.0.0.0', # noqa S104 port=8000, workers=2, threads=2, websockets=False, - interface=Interfaces.ASGI + interface=Interfaces.ASGI, ) granian_instance.serve() diff --git a/services/viewed.py b/services/viewed.py index 5e15876d..0b4312be 100644 --- a/services/viewed.py +++ b/services/viewed.py @@ -65,8 +65,8 @@ class ViewedStorage: start_date = creation_time.strftime('%Y-%m-%d') self.date_range = f'{start_date},{end_date}' - views_stat_task = asyncio.create_task(self.worker()) - logger.info(views_stat_task) + _views_stat_task = asyncio.create_task(self.worker()) + # logger.info(views_stat_task) else: logger.info(' * Пожалуйста, добавьте ключевой файл Google Analytics') self.disabled = True @@ -207,7 +207,6 @@ class ViewedStorage: while True: try: - logger.info(' - Обновление записей...') await self.update_pages() failed = 0 except Exception: