load_shouts_unrated-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s
This commit is contained in:
parent
626e899ca3
commit
543b2e6b4d
|
@ -10,10 +10,10 @@ from services.auth import login_required
|
||||||
from services.cache import (
|
from services.cache import (
|
||||||
cache_author,
|
cache_author,
|
||||||
get_cached_author,
|
get_cached_author,
|
||||||
|
get_cached_author_by_user_id,
|
||||||
get_cached_author_followers,
|
get_cached_author_followers,
|
||||||
get_cached_follower_authors,
|
get_cached_follower_authors,
|
||||||
get_cached_follower_topics,
|
get_cached_follower_topics,
|
||||||
get_cached_author_by_user_id
|
|
||||||
)
|
)
|
||||||
from services.db import local_session
|
from services.db import local_session
|
||||||
from services.logger import root_logger as logger
|
from services.logger import root_logger as logger
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
from sqlalchemy import bindparam, distinct, or_, text
|
|
||||||
from sqlalchemy.orm import aliased, joinedload
|
from sqlalchemy.orm import aliased, joinedload
|
||||||
from sqlalchemy.sql.expression import and_, asc, case, desc, func, nulls_last, select
|
from sqlalchemy.sql.expression import and_, asc, bindparam, case, desc, distinct, func, nulls_last, or_, select, text
|
||||||
|
|
||||||
from orm.author import Author, AuthorFollower
|
from orm.author import Author, AuthorFollower
|
||||||
from orm.reaction import Reaction, ReactionKind
|
from orm.reaction import Reaction, ReactionKind
|
||||||
|
@ -329,12 +328,12 @@ async def load_shouts_unrated(_, info, limit: int = 50, offset: int = 0):
|
||||||
q.outerjoin(
|
q.outerjoin(
|
||||||
Reaction,
|
Reaction,
|
||||||
and_(
|
and_(
|
||||||
Reaction.shout == Shout.id,
|
Reaction.shout_id == Shout.id,
|
||||||
Reaction.reply_to.is_(None),
|
Reaction.reply_to.is_(None),
|
||||||
Reaction.kind.in_([ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]),
|
Reaction.kind.in_([ReactionKind.LIKE.value, ReactionKind.DISLIKE.value]),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.outerjoin(Author, Author.user == bindparam("user_id"))
|
.outerjoin(Author, and_(Author.user == bindparam("user_id"), Reaction.created_by == Author.id))
|
||||||
.where(
|
.where(
|
||||||
and_(
|
and_(
|
||||||
Shout.deleted_at.is_(None),
|
Shout.deleted_at.is_(None),
|
||||||
|
|
|
@ -21,12 +21,11 @@ async def request_data(gql, headers=None):
|
||||||
logger.error(f"HTTP Errors: {errors}")
|
logger.error(f"HTTP Errors: {errors}")
|
||||||
else:
|
else:
|
||||||
return data
|
return data
|
||||||
except Exception as e:
|
except Exception as _e:
|
||||||
# Handling and logging exceptions during authentication check
|
# Handling and logging exceptions during authentication check
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
logger.error(f"request_data error: {e}")
|
logger.error(f"request_data error: {traceback.format_exc()}")
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ async def precache_data():
|
||||||
for author in authors:
|
for author in authors:
|
||||||
profile = author.dict() if not isinstance(author, dict) else author
|
profile = author.dict() if not isinstance(author, dict) else author
|
||||||
author_id = profile.get("id")
|
author_id = profile.get("id")
|
||||||
user_id = profile.get("user","").strip()
|
user_id = profile.get("user", "").strip()
|
||||||
if author_id and user_id:
|
if author_id and user_id:
|
||||||
authors_by_id[author_id] = profile
|
authors_by_id[author_id] = profile
|
||||||
await cache_author(profile)
|
await cache_author(profile)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user