debug-follow

This commit is contained in:
Untone 2024-03-11 11:16:12 +03:00
parent 94be60304e
commit 20cc14adc6
5 changed files with 14 additions and 22 deletions

View File

@ -86,7 +86,7 @@ async def get_author_by_user_id(user_id: str):
author_id = author.get('id')
author_slug = author.get('slug')
if author_id:
logger.debug(f'got author @{author_slug} #{author_id} cached today')
logger.debug(f'got author @{author_slug} #{author_id} cached')
return author
q = select(Author).filter(Author.user == user_id)
@ -278,7 +278,7 @@ async def get_author_followers(_, _info, slug: str):
logger.debug(f'@{slug} cache updated with {len(results)} followers')
return results
else:
logger.debug(f'@{slug} got followers cached today')
logger.debug(f'@{slug} got followers cached')
return json.loads(cached)
except Exception as exc:
import traceback

View File

@ -223,23 +223,13 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
shout_by_id = session.query(Shout).filter(Shout.id == shout_id).first()
if not shout_by_id:
return {'error': 'shout not found'}
if shout_by_id and slug != shout_by_id.slug:
same_slug_shout = (
session.query(Shout)
.filter(Shout.slug == shout_input.get('slug'))
.first()
)
if slug != shout_by_id.slug:
same_slug_shout = session.query(Shout).filter(Shout.slug == slug).first()
c = 1
while same_slug_shout is not None:
c += 1
slug += f'-{c}'
same_slug_shout = (
session.query(Shout)
.filter(
Shout.slug == slug
) # Use the updated slug value here
.first()
)
same_slug_shout = session.query(Shout).filter(Shout.slug == slug).first()
shout_input['slug'] = slug
if (
@ -279,6 +269,9 @@ async def update_shout(_, info, shout_id: int, shout_input=None, publish=False):
return {'error': 'access denied', 'shout': None}
except Exception as exc:
import traceback
traceback.print_exc()
logger.error(exc)
logger.error(f' cannot update with data: {shout_input}')

View File

@ -31,6 +31,7 @@ from services.rediscache import redis
@login_required
async def follow(_, info, what, slug):
follows = None
logger.debug(info.context['request'])
try:
user_id = info.context['user_id']
follower_query = (

View File

@ -1,17 +1,10 @@
from functools import wraps
import httpx
import logging
from starlette.exceptions import HTTPException
from services.logger import root_logger as logger
from settings import ADMIN_SECRET, AUTH_URL
trace_logger = logging.getLogger('_trace')
trace_logger.setLevel(logging.INFO)
httpx_logger = logging.getLogger('httpx')
httpx_logger.setLevel(logging.INFO)
async def request_data(gql, headers=None):
if headers is None:

View File

@ -69,3 +69,8 @@ def get_colorful_logger(name='main'):
root_logger = logging.getLogger()
root_logger.setLevel(logging.DEBUG)
root_logger.addHandler(stream)
ignore_logs = ['_trace', 'httpx', '_client', '_trace.atrace', 'aiohttp', '_client']
for lgr in ignore_logs:
loggr = logging.getLogger(lgr)
loggr.setLevel(logging.INFO)