This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import List
|
||||
import logging
|
||||
|
||||
from sqlalchemy import and_, case, distinct, func, literal, select, cast, Integer
|
||||
from sqlalchemy.orm import aliased
|
||||
@@ -17,6 +18,10 @@ from services.db import local_session
|
||||
from services.schema import mutation, query
|
||||
from services.unread import get_total_unread_counter
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("\t[resolvers.author]\t")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
|
||||
def add_author_stat_columns(q):
|
||||
shout_author_aliased = aliased(ShoutAuthor)
|
||||
@@ -48,7 +53,6 @@ def get_authors_from_query(q):
|
||||
"followings": followings_stat,
|
||||
}
|
||||
authors.append(author)
|
||||
# print(f"[resolvers.author] get_authors_from_query {authors}")
|
||||
return authors
|
||||
|
||||
|
||||
@@ -201,7 +205,7 @@ async def get_author(_, _info, slug="", author_id=None):
|
||||
@query.field("get_author_id")
|
||||
async def get_author_id(_, _info, user: str):
|
||||
with local_session() as session:
|
||||
print(f"[resolvers.author] getting author id for {user}")
|
||||
logger.info(f"[resolvers.author] getting author id for {user}")
|
||||
q = select(Author).filter(Author.user == user)
|
||||
return load_author_with_stats(q)
|
||||
|
||||
@@ -302,4 +306,4 @@ async def create_author(user_id: str, slug: str, name: str = ""):
|
||||
new_author = Author(user=user_id, slug=slug, name=name)
|
||||
session.add(new_author)
|
||||
session.commit()
|
||||
print(f"[resolvers.author] created by webhook {new_author.dict()}")
|
||||
logger.info(f"author created by webhook {new_author.dict()}")
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import List
|
||||
import logging
|
||||
|
||||
from sqlalchemy import select
|
||||
|
||||
@@ -19,6 +20,10 @@ from services.notify import notify_follower
|
||||
from services.schema import mutation, query
|
||||
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("\t[resolvers.reaction]\t")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
@login_required
|
||||
@mutation.field("follow")
|
||||
async def follow(_, info, what, slug):
|
||||
@@ -48,7 +53,7 @@ async def follow(_, info, what, slug):
|
||||
result = FollowingResult("NEW", "shout", slug)
|
||||
await FollowingManager.push("shout", result)
|
||||
except Exception as e:
|
||||
print(Exception(e))
|
||||
logger.error(e)
|
||||
return {"error": str(e)}
|
||||
|
||||
return {}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import time
|
||||
from typing import List
|
||||
import logging
|
||||
|
||||
from sqlalchemy import and_, asc, case, desc, func, select, text
|
||||
from sqlalchemy.orm import aliased, joinedload
|
||||
@@ -13,6 +14,10 @@ from services.notify import notify_reaction
|
||||
from services.schema import mutation, query
|
||||
|
||||
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger("\t[resolvers.reaction]\t")
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
def add_reaction_stat_columns(q):
|
||||
aliased_reaction = aliased(Reaction)
|
||||
|
||||
@@ -242,7 +247,7 @@ async def create_reaction(_, info, reaction):
|
||||
try:
|
||||
reactions_follow(author.id, reaction["shout"], True)
|
||||
except Exception as e:
|
||||
print(f"[resolvers.reactions] error on reactions auto following: {e}")
|
||||
logger.error(f"[resolvers.reactions] error on reactions auto following: {e}")
|
||||
|
||||
rdict["stat"] = {"commented": 0, "reacted": 0, "rating": 0}
|
||||
|
||||
@@ -438,8 +443,10 @@ async def load_shouts_followed(_, info, limit=50, offset=0) -> List[Shout]:
|
||||
with local_session() as session:
|
||||
author = session.query(Author).filter(Author.user == user_id).first()
|
||||
if author:
|
||||
author_id: int = author.dict()["id"]
|
||||
shouts = reacted_shouts_updates(author_id, limit, offset)
|
||||
return shouts
|
||||
else:
|
||||
return []
|
||||
try:
|
||||
author_id: int = author.dict()["id"]
|
||||
shouts = reacted_shouts_updates(author_id, limit, offset)
|
||||
return shouts
|
||||
except Exception as error:
|
||||
logger.debug(error)
|
||||
return []
|
||||
|
@@ -58,7 +58,7 @@ async def get_topics_all(_, _info):
|
||||
|
||||
|
||||
def topics_followed_by(author_id):
|
||||
q = select(Topic)
|
||||
q = select(Topic, TopicFollower)
|
||||
q = add_topic_stat_columns(q)
|
||||
q = q.join(TopicFollower).where(TopicFollower.follower == author_id)
|
||||
|
||||
|
Reference in New Issue
Block a user