Add "contradiction index" metric (#278)

* show the value of `controversy` in the hover on scores
* add a new sorting mode "controversial" to "sort by" dropdown
This commit is contained in:
Andrei Alikov
2019-02-17 17:48:49 -06:00
committed by Umputun
parent a2b9b39640
commit d62825642d
3 changed files with 11 additions and 1 deletions
+1
View File
@@ -489,6 +489,7 @@ type Comment struct {
Locator Locator `json:"locator"` // post locator
Score int `json:"score"` // comment score, read only
Votes map[string]bool `json:"votes"` // comment votes, read only
Controversy float64 `json:"controversy,omitempty"` // comment controversy, read only
Timestamp time.Time `json:"time"` // time stamp, read only
Pin bool `json:"pin"` // pinned status, read only
Delete bool `json:"delete"` // delete status, read only
@@ -187,6 +187,14 @@ function getSortArray(currentSort) {
value: '+active',
label: 'Least recently updated',
},
{
value: '-controversy',
label: 'Most controversial',
},
{
value: '+controversy',
label: 'Least controversial',
},
];
return sortArray.map(sort => {
+2 -1
View File
@@ -446,6 +446,7 @@ export default class Comment extends Component {
const o = {
...data,
controversyText: `Controversy: ${(data.controversy || 0).toFixed(2)}`,
text: data.text.length
? mods.view === 'preview'
? getTextSnippet(data.text)
@@ -597,7 +598,7 @@ export default class Comment extends Component {
Vote up
</span>
<span className="comment__score-value">
<span className="comment__score-value" title={o.controversyText}>
{o.score.sign}
{o.score.value}
</span>