Merge branch 'feature/core' of v2.discours.io:core into feature/core
Some checks failed
Deploy to core / deploy (push) Has been cancelled

This commit is contained in:
Untone 2024-01-28 10:03:51 +03:00
commit dd2ef55f04
6 changed files with 11 additions and 22 deletions

View File

@ -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'

View File

@ -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,

View File

@ -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"

View File

@ -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())))
)

View File

@ -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()

View File

@ -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: