feat: initial comment count support (#1903)

This commit is contained in:
Wyatt Johnson
2018-09-26 19:23:54 +00:00
committed by GitHub
parent b916914faa
commit 20170333ed
6 changed files with 164 additions and 24 deletions
@@ -6,6 +6,7 @@ const Asset: GQLAssetTypeResolver<Asset> = {
ctx.loaders.Comments.forAsset(asset.id, input),
// TODO: implement this.
isClosed: () => false,
commentCounts: asset => asset.comment_counts,
};
export default Asset;
@@ -0,0 +1,14 @@
import {
GQLCOMMENT_STATUS,
GQLCommentCountsTypeResolver,
} from "talk-server/graph/tenant/schema/__generated__/types";
import { CommentStatusCounts } from "talk-server/models/asset";
const CommentCounts: GQLCommentCountsTypeResolver<CommentStatusCounts> = {
totalVisible: commentCounts =>
commentCounts[GQLCOMMENT_STATUS.ACCEPTED] +
commentCounts[GQLCOMMENT_STATUS.NONE],
statuses: commentCounts => commentCounts,
};
export default CommentCounts;
@@ -4,6 +4,7 @@ import { GQLResolver } from "talk-server/graph/tenant/schema/__generated__/types
import Asset from "./asset";
import AuthIntegrations from "./auth_integrations";
import Comment from "./comment";
import CommentCounts from "./comment_counts";
import Mutation from "./mutation";
import Profile from "./profile";
import Query from "./query";
@@ -12,6 +13,7 @@ const Resolvers: GQLResolver = {
Asset,
AuthIntegrations,
Comment,
CommentCounts,
Cursor,
Mutation,
Profile,
@@ -265,7 +265,7 @@ type KarmaThreshold {
type KarmaThresholds {
"""
flag represents karma settings in relation to how well a User's flagging
ability aligns with the moderation decicions made by moderators.
ability aligns with the moderation decisions made by moderators.
"""
flag: KarmaThreshold!
@@ -284,7 +284,7 @@ type Karma {
"""
karmaThresholds contains the currently set thresholds for triggering Trust
beheviour.
behavior.
"""
thresholds: KarmaThresholds!
}
@@ -741,6 +741,50 @@ type CommentsConnection {
pageInfo: PageInfo!
}
################################################################################
## CommentCounts
################################################################################
type CommentStatusCounts {
"""
The comment is not PREMOD, but was not applied a moderation status by a
moderator.
"""
NONE: Int!
"""
The comment has been accepted by a moderator.
"""
ACCEPTED: Int!
"""
The comment has been rejected by a moderator.
"""
REJECTED: Int!
"""
The comment was created while the asset's premoderation option was on, and
new comments that haven't been moderated yet are referred to as
"premoderated" or "premod" comments.
"""
PREMOD: Int!
"""
SYSTEM_WITHHELD represents a comment that was withheld by the system because
it was flagged by an internal process for further review.
"""
SYSTEM_WITHHELD: Int!
}
type CommentCounts {
"""
totalVisible will return the count of all visible Comments.
"""
totalVisible: Int!
statuses: CommentStatusCounts! @auth(roles: [ADMIN, MODERATOR])
}
################################################################################
## Asset
################################################################################
@@ -795,6 +839,11 @@ type Asset {
"""
isClosed: Boolean!
"""
commentCounts stores all the counts of Comments that are left on the Comment.
"""
commentCounts: CommentCounts!
"""
createdAt is the date that the Asset was created at.
"""
@@ -1119,7 +1168,7 @@ input SettingsKarmaThresholdInput {
input SettingsKarmaThresholdsInput {
"""
flag represents karma settings in relation to how well a User's flagging
ability aligns with the moderation decicions made by moderators.
ability aligns with the moderation decisions made by moderators.
"""
flag: SettingsKarmaThresholdInput
@@ -1138,7 +1187,7 @@ input SettingsKarmaInput {
"""
karmaThresholds contains the currently set thresholds for triggering Trust
beheviour.
behavior.
"""
thresholds: SettingsKarmaThresholdsInput
}