server side

This commit is contained in:
Wyatt Johnson
2018-05-17 11:38:00 -06:00
parent 6444e8c2ab
commit 887f7e17f4
5 changed files with 27 additions and 5 deletions
@@ -245,9 +245,12 @@ class UserDetail extends React.Component {
<KarmaTooltip />
</div>
<span
className={cn(styles.statKarmaResult, styles[getKarma(100)])}
className={cn(
styles.statKarmaResult,
styles[getKarma(user.reliable.commenter)]
)}
>
{100}
{user.reliable.commenterScore}
</span>
</li>
</ul>
@@ -185,6 +185,8 @@ export const withUserDetailQuery = withQuery(
}
reliable {
flagger
commenter
commenterScore
}
state {
status {
+3 -3
View File
@@ -55,10 +55,10 @@ export const canUsernameBeUpdated = status => {
* retrieves karma value as string
*/
export const getKarma = score => {
if (score === 0) {
export const getKarma = reliability => {
if (reliability === null) {
return 'neutral';
} else if (score) {
} else if (reliability) {
return 'good';
} else {
return 'bad';
+8
View File
@@ -20,9 +20,17 @@ type Reliability {
# `null` if the reliability cannot be determined.
flagger: Boolean
# flaggerScore will contains the number of agreed flags vs disagred flag
# count.
flaggerScore: Int!
# Commenter will be `true` when the commenter is reliable, `false` if not, or
# `null` if the reliability cannot be determined.
commenter: Boolean
# commenterScore the number of approved comments (not untouched) subtracted by
# the number of rejected comments.
commenterScore: Int!
}
################################################################################
+9
View File
@@ -1,6 +1,7 @@
const debug = require('debug')('talk:services:karma');
const UserModel = require('../models/user');
const { TRUST_THRESHOLDS } = require('../config');
const { get } = require('lodash');
/**
* This will create an object with the property name of the action type as the
@@ -83,9 +84,17 @@ class KarmaModel {
return KarmaService.isReliable('flag', this.model);
}
get flaggerScore() {
return get(this.model, 'flag.karma', 0);
}
get commenter() {
return KarmaService.isReliable('comment', this.model);
}
get commenterScore() {
return get(this.model, 'comment.karma', 0);
}
}
/**