fixes
This commit is contained in:
parent
aee83c31b5
commit
f0fc09b1a1
|
@ -210,5 +210,5 @@ async def load_authors_by(_, info, by, limit, offset):
|
||||||
for a in authors:
|
for a in authors:
|
||||||
a.stat = await get_author_stat(a.slug)
|
a.stat = await get_author_stat(a.slug)
|
||||||
authors = list(set(authors))
|
authors = list(set(authors))
|
||||||
authors = sorted(authors, key=lambda a: a["stat"].get(by.get("stat")))
|
# authors = sorted(authors, key=lambda a: a["stat"].get(by.get("stat")))
|
||||||
return authors
|
return authors
|
||||||
|
|
|
@ -217,13 +217,10 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
|
||||||
:return: Reaction[]
|
:return: Reaction[]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
q = select(Reaction).options(
|
q = select(Reaction).join(
|
||||||
selectinload(Reaction.shout),
|
Shout
|
||||||
).where(
|
).where(
|
||||||
Reaction.deletedAt.is_(None)
|
Reaction.deletedAt.is_(None)
|
||||||
).join(
|
|
||||||
Shout,
|
|
||||||
Shout.slug == Reaction.shout
|
|
||||||
)
|
)
|
||||||
if by.get("slug"):
|
if by.get("slug"):
|
||||||
q = q.filter(Shout.slug == by["slug"])
|
q = q.filter(Shout.slug == by["slug"])
|
||||||
|
@ -243,8 +240,9 @@ async def load_reactions_by(_, info, by, limit=50, offset=0):
|
||||||
if by.get("days"):
|
if by.get("days"):
|
||||||
before = datetime.now() - timedelta(days=int(by["days"]) or 30)
|
before = datetime.now() - timedelta(days=int(by["days"]) or 30)
|
||||||
q = q.filter(Reaction.createdAt > before)
|
q = q.filter(Reaction.createdAt > before)
|
||||||
q = q.group_by(Shout.id).order_by(
|
|
||||||
desc(by.get("order") or "createdAt")
|
q = q.group_by(Reaction.id).order_by(
|
||||||
|
desc(by.get("order") or Reaction.createdAt)
|
||||||
).limit(limit).offset(offset)
|
).limit(limit).offset(offset)
|
||||||
|
|
||||||
rrr = []
|
rrr = []
|
||||||
|
|
|
@ -18,11 +18,14 @@ from services.stat.reacted import ReactedStorage
|
||||||
|
|
||||||
@query.field("loadShout")
|
@query.field("loadShout")
|
||||||
async def load_shout(_, info, slug):
|
async def load_shout(_, info, slug):
|
||||||
shout = select(Shout).options(
|
with local_session() as session:
|
||||||
|
shout = session.query(Shout).options(
|
||||||
# TODO add cation
|
# TODO add cation
|
||||||
selectinload(Shout.authors),
|
selectinload(Shout.authors),
|
||||||
selectinload(Shout.topics),
|
selectinload(Shout.topics),
|
||||||
).where(
|
).filter(
|
||||||
|
Shout.slug == slug
|
||||||
|
).filter(
|
||||||
Shout.deletedAt.is_(None)
|
Shout.deletedAt.is_(None)
|
||||||
).one()
|
).one()
|
||||||
|
|
||||||
|
|
|
@ -277,7 +277,7 @@ type Query {
|
||||||
userFollowedAuthors(slug: String!): [Author]!
|
userFollowedAuthors(slug: String!): [Author]!
|
||||||
userFollowedTopics(slug: String!): [Topic]!
|
userFollowedTopics(slug: String!): [Topic]!
|
||||||
authorsAll: [Author]!
|
authorsAll: [Author]!
|
||||||
getAuthor(slug: String!): User!
|
getAuthor(slug: String!): User
|
||||||
|
|
||||||
# collab
|
# collab
|
||||||
getCollabs: [Collab]!
|
getCollabs: [Collab]!
|
||||||
|
@ -286,7 +286,7 @@ type Query {
|
||||||
markdownBody(body: String!): String!
|
markdownBody(body: String!): String!
|
||||||
|
|
||||||
# topics
|
# topics
|
||||||
getTopic(slug: String!): Topic!
|
getTopic(slug: String!): Topic
|
||||||
topicsAll: [Topic]!
|
topicsAll: [Topic]!
|
||||||
topicsRandom(amount: Int): [Topic]!
|
topicsRandom(amount: Int): [Topic]!
|
||||||
topicsByCommunity(community: String!): [Topic]!
|
topicsByCommunity(community: String!): [Topic]!
|
||||||
|
|
Loading…
Reference in New Issue
Block a user