revised
This commit is contained in:
parent
910f8f59e6
commit
82fe60f764
|
@ -129,3 +129,7 @@ def get_subscribed_shout_comments(slug):
|
||||||
all()
|
all()
|
||||||
slugs = [row.shout for row in rows]
|
slugs = [row.shout for row in rows]
|
||||||
return slugs
|
return slugs
|
||||||
|
|
||||||
|
def get_top10_comments():
|
||||||
|
with local_session() as session:
|
||||||
|
rows = session.query(Comment).limit(10).all()
|
||||||
|
|
|
@ -98,17 +98,18 @@ async def user_comments(_, info, slug, page, size):
|
||||||
|
|
||||||
return comments
|
return comments
|
||||||
|
|
||||||
@query.field("userSubscriptions")
|
@query.field("userSubscribedAuthors")
|
||||||
async def user_subscriptions(_, info, slug):
|
async def user_subscriptions(_, info, slug):
|
||||||
return _get_user_subscribed_authors(slug)
|
slugs = _get_user_subscribed_authors(slug)
|
||||||
|
return slugs
|
||||||
|
|
||||||
@query.field("userSubscribers")
|
@query.field("userSubscribers")
|
||||||
async def user_subscribers(_, info, slug):
|
async def user_subscribers(_, info, slug):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
users = session.query(User).\
|
slugs = session.query(User.slug).\
|
||||||
join(AuthorSubscription, User.slug == AuthorSubscription.subscriber).\
|
join(AuthorSubscription, User.slug == AuthorSubscription.subscriber).\
|
||||||
where(AuthorSubscription.author == slug)
|
where(AuthorSubscription.author == slug)
|
||||||
return users
|
return slugs
|
||||||
|
|
||||||
@query.field("userSubscribedTopics")
|
@query.field("userSubscribedTopics")
|
||||||
async def user_subscribed_topics(_, info, slug):
|
async def user_subscribed_topics(_, info, slug):
|
||||||
|
|
|
@ -13,16 +13,21 @@ async def topics_by_slugs(_, info, slugs = None):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
topics = await TopicStorage.get_topics(slugs)
|
topics = await TopicStorage.get_topics(slugs)
|
||||||
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
|
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
|
||||||
if "topicStat" in all_fields:
|
if "stat" in all_fields:
|
||||||
for topic in topics:
|
for topic in topics:
|
||||||
topic.topicStat = await TopicStat.get_stat(topic.slug)
|
topic.stat = await TopicStat.get_stat(topic.slug)
|
||||||
return topics
|
return topics
|
||||||
|
|
||||||
@query.field("topicsByCommunity")
|
@query.field("topicsByCommunity")
|
||||||
async def topics_by_community(_, info, community):
|
async def topics_by_community(_, info, community):
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
return await TopicStorage.get_topics_by_community(community)
|
topics = await TopicStorage.get_topics_by_community(community)
|
||||||
|
all_fields = [node.name.value for node in info.field_nodes[0].selection_set.selections]
|
||||||
|
if "stat" in all_fields:
|
||||||
|
for topic in topics:
|
||||||
|
topic.stat = await TopicStat.get_stat(topic.slug)
|
||||||
|
return topics
|
||||||
|
|
||||||
@query.field("topicsByAuthor")
|
@query.field("topicsByAuthor")
|
||||||
async def topics_by_author(_, info, author):
|
async def topics_by_author(_, info, author):
|
||||||
slugs = set()
|
slugs = set()
|
||||||
|
|
|
@ -159,33 +159,46 @@ type Mutation {
|
||||||
################################### Query
|
################################### Query
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
|
|
||||||
# auth
|
# auth
|
||||||
isEmailUsed(email: String!): Boolean!
|
isEmailUsed(email: String!): Boolean!
|
||||||
signIn(email: String!, password: String): AuthResult!
|
signIn(email: String!, password: String): AuthResult!
|
||||||
signOut: Result!
|
signOut: Result!
|
||||||
|
forget(email: String!): Result!
|
||||||
|
requestPasswordReset(email: String!): Result!
|
||||||
|
updatePassword(password: String!, token: String!): Result!
|
||||||
|
|
||||||
# profile
|
# profile
|
||||||
|
userSubscribers(slug: String!): [String]!
|
||||||
|
userSubscribedAuthors(slug: String!): [String]!
|
||||||
|
userSubscribedTopics(slug: String!): [String]!
|
||||||
getCurrentUser: UserResult!
|
getCurrentUser: UserResult!
|
||||||
getUsersBySlugs(slugs: [String]!): [User]!
|
getUsersBySlugs(slugs: [String]!): [User]!
|
||||||
getUserRoles(slug: String!): [Role]!
|
getUserRoles(slug: String!): [Role]!
|
||||||
userComments(slug: String!, page: Int!, size: Int!): [Comment]!
|
|
||||||
userSubscriptions(slug: String!): [User]!
|
|
||||||
userSubscribers(slug: String!): [User]!
|
|
||||||
userSubscribedTopics(slug: String!): [String]!
|
|
||||||
|
|
||||||
shoutsRatedByUser(page: Int!, size: Int!): ShoutsResult!
|
|
||||||
shoutsCommentedByUser(slug: String!, page: Int!, size: Int!): [Shout]!
|
|
||||||
userUnpublishedShouts(page: Int!, size: Int!): ShoutsResult!
|
|
||||||
|
|
||||||
# shouts
|
# shouts
|
||||||
getShoutBySlug(slug: String!): Shout!
|
getShoutBySlug(slug: String!): Shout!
|
||||||
shoutsByTopics(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
shoutsByTopics(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
||||||
shoutsByAuthors(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
shoutsByAuthors(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
||||||
shoutsByCommunities(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
shoutsByCommunities(slugs: [String]!, page: Int!, size: Int!): [Shout]!
|
||||||
|
shoutsRatedByUser(page: Int!, size: Int!): ShoutsResult!
|
||||||
|
shoutsReviewed(page: Int!, size: Int!): [Shout]!
|
||||||
|
userUnpublishedShouts(page: Int!, size: Int!): ShoutsResult!
|
||||||
|
shoutsCommentedByUser(page: Int!, size: Int!): ShoutsResult!
|
||||||
|
recentCommented(page: Int!, size: Int!): [Shout]!
|
||||||
|
|
||||||
|
# comments
|
||||||
getShoutComments(slug: String!): [Comment]!
|
getShoutComments(slug: String!): [Comment]!
|
||||||
|
getAllComments: [Comment]! # top10
|
||||||
|
userComments(slug: String!, page: Int!, size: Int!): [Comment]!
|
||||||
|
|
||||||
# collab
|
# collab
|
||||||
getShoutProposals(slug: String!): [Proposal]!
|
getShoutProposals(slug: String!): [Proposal]!
|
||||||
|
createProposal(body: String!, range: String): Proposal!
|
||||||
|
updateProposal(body: String!, range: String): Proposal!
|
||||||
|
destroyProposal(id: Int!): Result!
|
||||||
|
inviteAuthor(slug: String!, author: String!): Result!
|
||||||
|
removeAuthor(slug: String!, author: String!): Result!
|
||||||
|
|
||||||
# mainpage
|
# mainpage
|
||||||
topViewed(page: Int!, size: Int!): [Shout]!
|
topViewed(page: Int!, size: Int!): [Shout]!
|
||||||
|
@ -197,18 +210,14 @@ type Query {
|
||||||
recentAll(page: Int!, size: Int!): [Shout]!
|
recentAll(page: Int!, size: Int!): [Shout]!
|
||||||
|
|
||||||
# topics
|
# topics
|
||||||
topicsAll(slugs: [String]): [Topic]!
|
topicsAll(page: Int!, size: Int!): [Topic]!
|
||||||
topicsByCommunity(community: String!): [Topic]!
|
topicsByCommunity(community: String!): [Topic]!
|
||||||
topicsByAuthor(author: String!): [Topic]!
|
topicsByAuthor(author: String!): [Topic]!
|
||||||
|
|
||||||
# getOnlineUsers: [User!]!
|
|
||||||
|
|
||||||
# communities
|
# communities
|
||||||
getCommunity(slug: String): Community!
|
getCommunity(slug: String): Community!
|
||||||
getCommunities: [Community]!
|
getCommunities: [Community]!
|
||||||
|
# TODO: getCommunityMembers(slug: String!): [User]!
|
||||||
shoutsReviewed(page: Int!, size: Int!): [Shout]!
|
|
||||||
recentCommented(page: Int!, size: Int!): [Shout]!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
############################################ Subscription
|
############################################ Subscription
|
||||||
|
@ -365,7 +374,7 @@ type Topic {
|
||||||
parents: [String] # NOTE: topic can have parent topics
|
parents: [String] # NOTE: topic can have parent topics
|
||||||
children: [String] # and children
|
children: [String] # and children
|
||||||
community: String!
|
community: String!
|
||||||
topicStat: TopicStat
|
stat: TopicStat
|
||||||
oid: String
|
oid: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user