getTopic, getAuthor
This commit is contained in:
parent
503d6daa93
commit
1720f00839
|
@ -34,7 +34,6 @@ async def get_author_stat(slug):
|
||||||
return {
|
return {
|
||||||
"followers": session.query(AuthorFollower).where(AuthorFollower.author == slug).count(),
|
"followers": session.query(AuthorFollower).where(AuthorFollower.author == slug).count(),
|
||||||
"rating": session.query(func.sum(UserRating.value)).where(UserRating.user == slug).first()
|
"rating": session.query(func.sum(UserRating.value)).where(UserRating.user == slug).first()
|
||||||
# TODO: debug
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,3 +209,10 @@ async def get_authors_all(_, _info):
|
||||||
@query.field("topAuthors")
|
@query.field("topAuthors")
|
||||||
def get_top_authors(_, _info, offset, limit):
|
def get_top_authors(_, _info, offset, limit):
|
||||||
return list(UserStorage.get_top_users())[offset : offset + limit] # type: ignore
|
return list(UserStorage.get_top_users())[offset : offset + limit] # type: ignore
|
||||||
|
|
||||||
|
|
||||||
|
@query.field("getAuthor")
|
||||||
|
async def get_author(_, _info, slug):
|
||||||
|
a = await UserStorage.users[slug]
|
||||||
|
a.stat = get_author_stat(slug)
|
||||||
|
return a
|
||||||
|
|
|
@ -53,6 +53,13 @@ async def topics_by_author(_, _info, author):
|
||||||
return list(author_topics)
|
return list(author_topics)
|
||||||
|
|
||||||
|
|
||||||
|
@query.field("getTopic")
|
||||||
|
async def get_topic(_, _info, slug):
|
||||||
|
t = await TopicStorage.topics[slug]
|
||||||
|
t.stat = get_topic_stat(slug)
|
||||||
|
return t
|
||||||
|
|
||||||
|
|
||||||
@mutation.field("createTopic")
|
@mutation.field("createTopic")
|
||||||
@login_required
|
@login_required
|
||||||
async def create_topic(_, _info, inp):
|
async def create_topic(_, _info, inp):
|
||||||
|
|
|
@ -214,6 +214,7 @@ type Query {
|
||||||
userReactedShouts(slug: String!): [Shout]! # test
|
userReactedShouts(slug: String!): [Shout]! # test
|
||||||
getUserRoles(slug: String!): [Role]!
|
getUserRoles(slug: String!): [Role]!
|
||||||
authorsAll: [User]!
|
authorsAll: [User]!
|
||||||
|
getAuthor(slug: String!): User!
|
||||||
|
|
||||||
# shouts
|
# shouts
|
||||||
getShoutBySlug(slug: String!): Shout!
|
getShoutBySlug(slug: String!): Shout!
|
||||||
|
@ -244,6 +245,7 @@ type Query {
|
||||||
markdownBody(body: String!): String!
|
markdownBody(body: String!): String!
|
||||||
|
|
||||||
# topics
|
# topics
|
||||||
|
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