Merge branch 'feature/core' of v2.discours.io:core into feature/core
Some checks failed
Deploy to core / deploy (push) Has been cancelled
Some checks failed
Deploy to core / deploy (push) Has been cancelled
This commit is contained in:
commit
dd2ef55f04
|
@ -1,8 +1,5 @@
|
||||||
name: 'Deploy to core'
|
name: 'Deploy to core'
|
||||||
on:
|
on: [push]
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
|
@ -24,8 +21,7 @@ jobs:
|
||||||
- name: Push to dokku
|
- name: Push to dokku
|
||||||
uses: dokku/github-action@master
|
uses: dokku/github-action@master
|
||||||
with:
|
with:
|
||||||
branch: 'main'
|
branch: 'feature/core'
|
||||||
git_remote_url: 'ssh://dokku@v2.discours.io:22/core'
|
git_remote_url: 'ssh://dokku@v2.discours.io:22/core'
|
||||||
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
ssh_private_key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
git_push_flags: '--force'
|
git_push_flags: '--force'
|
||||||
|
|
6
main.py
6
main.py
|
@ -2,6 +2,7 @@ import os
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
|
||||||
|
import sentry_sdk
|
||||||
from ariadne import load_schema_from_path, make_executable_schema
|
from ariadne import load_schema_from_path, make_executable_schema
|
||||||
from ariadne.asgi import GraphQL
|
from ariadne.asgi import GraphQL
|
||||||
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
|
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():
|
async def start_up():
|
||||||
print(f'[main] starting in {MODE} mode')
|
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
|
# start viewed service
|
||||||
await ViewedStorage.init()
|
await ViewedStorage.init()
|
||||||
|
@ -40,8 +42,6 @@ async def start_up():
|
||||||
if MODE == 'production':
|
if MODE == 'production':
|
||||||
# sentry monitoring
|
# sentry monitoring
|
||||||
try:
|
try:
|
||||||
import sentry_sdk
|
|
||||||
|
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
SENTRY_DSN,
|
SENTRY_DSN,
|
||||||
enable_tracing=True,
|
enable_tracing=True,
|
||||||
|
|
|
@ -11,7 +11,7 @@ python = "^3.12"
|
||||||
SQLAlchemy = "^2.0.22"
|
SQLAlchemy = "^2.0.22"
|
||||||
psycopg2-binary = "^2.9.9"
|
psycopg2-binary = "^2.9.9"
|
||||||
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
redis = {extras = ["hiredis"], version = "^5.0.1"}
|
||||||
sentry-sdk = "^1.39.1"
|
sentry-sdk = "^1.4.1"
|
||||||
starlette = "^0.36.1"
|
starlette = "^0.36.1"
|
||||||
gql = "^3.4.1"
|
gql = "^3.4.1"
|
||||||
ariadne = "^0.21"
|
ariadne = "^0.21"
|
||||||
|
|
|
@ -4,7 +4,6 @@ from sqlalchemy.sql.expression import and_, asc, case, desc, func, nulls_last, s
|
||||||
from starlette.exceptions import HTTPException
|
from starlette.exceptions import HTTPException
|
||||||
|
|
||||||
from orm.author import Author, AuthorFollower
|
from orm.author import Author, AuthorFollower
|
||||||
from orm.community import Community
|
|
||||||
from orm.reaction import Reaction, ReactionKind
|
from orm.reaction import Reaction, ReactionKind
|
||||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
|
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
|
||||||
from orm.topic import Topic, TopicFollower
|
from orm.topic import Topic, TopicFollower
|
||||||
|
@ -316,12 +315,7 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
|
||||||
.options(
|
.options(
|
||||||
joinedload(Shout.authors),
|
joinedload(Shout.authors),
|
||||||
joinedload(Shout.topics),
|
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())))
|
.where(and_(Shout.deleted_at.is_(None), Shout.slug.in_(results_dict.keys())))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
granian_instance = Granian(
|
granian_instance = Granian(
|
||||||
'main:app',
|
'main:app',
|
||||||
address='0.0.0.0', # noqa S104
|
address='0.0.0.0', # noqa S104
|
||||||
port=8000,
|
port=8000,
|
||||||
workers=2,
|
workers=2,
|
||||||
threads=2,
|
threads=2,
|
||||||
websockets=False,
|
websockets=False,
|
||||||
interface=Interfaces.ASGI
|
interface=Interfaces.ASGI,
|
||||||
)
|
)
|
||||||
granian_instance.serve()
|
granian_instance.serve()
|
||||||
|
|
|
@ -65,8 +65,8 @@ class ViewedStorage:
|
||||||
start_date = creation_time.strftime('%Y-%m-%d')
|
start_date = creation_time.strftime('%Y-%m-%d')
|
||||||
self.date_range = f'{start_date},{end_date}'
|
self.date_range = f'{start_date},{end_date}'
|
||||||
|
|
||||||
views_stat_task = asyncio.create_task(self.worker())
|
_views_stat_task = asyncio.create_task(self.worker())
|
||||||
logger.info(views_stat_task)
|
# logger.info(views_stat_task)
|
||||||
else:
|
else:
|
||||||
logger.info(' * Пожалуйста, добавьте ключевой файл Google Analytics')
|
logger.info(' * Пожалуйста, добавьте ключевой файл Google Analytics')
|
||||||
self.disabled = True
|
self.disabled = True
|
||||||
|
@ -207,7 +207,6 @@ class ViewedStorage:
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
logger.info(' - Обновление записей...')
|
|
||||||
await self.update_pages()
|
await self.update_pages()
|
||||||
failed = 0
|
failed = 0
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user