153

When viewing your own flag history, I feel it would be valuable to show what percentage of flags have been marked as helpful.

I've implemented this as a userscript but would like to make a formal feature-request.

This is the result I came up with:

Overall Helpful Flag Percentage

Feature Request Ideas

  • Change the percentage color based on some sort of grading scale (90%, 80%, 70%)
  • Display a warning when users are approaching a dangerous threshold
  • Display the percentage as a progress bar
  • Show a unicorn for 100% helpful users (I'm kidding...maybe?)

The UserScript

This script does not count pending, aged away and disputed flags.

I did not include the disputed flags in the total for the following reason:

A disputed flag is whenever your flag was dismissed as neither helpful or declined, someone reviewed your flag but no conclusive action was taken

Here is the userscript for those who are interested. Feel free to change whatever you like.

// ==UserScript==
// @name         Helpful Flag Percentage
// @namespace    https://stackoverflow.com/users/1454538/
// @author       enki
// @match        *://*.stackexchange.com/users/flag-summary/*
// @match        *://*.stackoverflow.com/users/flag-summary/*
// @match        *://*.stackapps.com/users/flag-summary/*
// ==/UserScript==
/*jslint browser: true, white: true*/
/*jslint this */
/*global $, jQuery*/
$(function () {
'use strict';

    var helpfulFlags = 0;
    $("td > a:contains('helpful')").parent().prev().each(function () {
        helpfulFlags += parseInt($(this).text().replace(",",""));
    });

    var declinedFlags = 0;
    $("td > a:contains('declined')").parent().prev().each(function () {
        declinedFlags += parseInt($(this).text().replace(",",""));
    });

    if (helpfulFlags > 0) {

        var percentHelpful = Number(Math.round((helpfulFlags / (helpfulFlags + declinedFlags)) * 100 + 'e2') + 'e-2');

        if (percentHelpful > 100 ) {
            percentHelpful = 100;
        }

        var percentColor;
        if (percentHelpful >= 90) {
            percentColor = "limegreen";
        } else if (percentHelpful >= 80) {
            percentColor = "darkorange";
        } else if (percentHelpful < 80) {
            percentColor = "red";
        } 

        var css = "<style>\
                    #progress {\
                        background: #ccc;\
                        height: 10px;\
                        width: 220px;\
                        margin: 6px 10px 10px 0;\
                        padding: 0px;\
                   }\
                    #progress:after {\
                        content: '';\
                        display: block;\
                        background: " + percentColor + ";\
                        width: " + percentHelpful + "%;\
                        height: 100%;\
                    }\
                    #percentHelpful {\
                        margin-bottom: 5px;\
                    }\
                    </style>";

        $('head').append(css);

        $("#flag-stat-info-table").before("<h3 id='percentHelpful' title='pending, aged away and disputed flags are not counted'><span id='percent'>" + percentHelpful + "%</span> helpful</h3>");
        $("span#percent").css("color", percentColor);

        $("#percentHelpful").after("<div id='progress'></div>");
    }
});
30
  • 27
    I'm getting a very high helpful rate ;) But it is correct on meta. Commented Nov 23, 2015 at 7:28
  • 38
    I should've posted to Code Review first :)
    – matt.
    Commented Nov 23, 2015 at 7:32
  • 5
    Or StackApps?
    – IKavanagh
    Commented Nov 23, 2015 at 11:58
  • 1
    Flagged for migration. ;) Commented Nov 23, 2015 at 15:24
  • 1
    @IKavanagh Yeah, it's been implemented into SE Additional Optional Features but this is an actual feature request.
    – matt.
    Commented Nov 23, 2015 at 15:25
  • 2
    Along with some guide as to what percentage most users have. I think we should be aiming for something much stricter than a usual 90/80/70/60 scale.
    – Teepeemm
    Commented Nov 23, 2015 at 15:33
  • 3
    @Teepeemm, the problem with comparing to "most users" is that "most users" can't flag or flag very little.
    – Andy Mod
    Commented Nov 23, 2015 at 15:53
  • 1
    Rate limit at that low of a percentage maybe (if over n total flags), but a full on ban puts you into a situation you can't recover from. flags, unlike posts, can't be improved.
    – Kevin B
    Commented Nov 23, 2015 at 16:08
  • 2
    Dupe of meta.stackexchange.com/questions/209065/…?
    – j08691
    Commented Nov 23, 2015 at 17:19
  • 1
    @CalebKleveter Yes. Some of the errors are valid, I forgot some spaces, ect... See this answer though.
    – matt.
    Commented Nov 23, 2015 at 18:40
  • 2
    so.. basically just: percentHelpful = helpfulFlags / (helpfulFlags + declinedFlags) * 100 (ditching totalFlags, pendingFlags, agedFlags and disputedFlags) ?
    – GitaarLAB
    Commented Nov 23, 2015 at 22:46
  • 1
    Kind of unfair, only 18 flags aged away. That's about 10% of your overall flags. I have a third of my flags aged away. Maybe I should only flag obvious things...
    – usr1234567
    Commented Nov 24, 2015 at 6:05
  • 5
    @HelpingHands Simplest way. 1. Copy the script 2. Go to your flags page 3. Open console 4. Paste code 5. Click enter 6. Enjoy and teach others Commented Nov 24, 2015 at 8:49
  • 3
    @BhargavRao - Excellent , I got 91.52% helpful :) . Thanks for quick direction. Commented Nov 24, 2015 at 8:53
  • 3
    I think it's an attempt or solution (not sure yet) to either increase precision and/or work around floating-point limitation/behavior. Personally I was contemplating: percentHelpful=(Math.round(helpfulFlags*1e4/(helpfulFlags + declinedFlags))/100).toFixed(2) (which should give a useful max range of floor((2^53)/10000)===900719925474). That should keep the math in integers for 2 decimal digits, rounded and append up to 2 zero's using toFixed.
    – GitaarLAB
    Commented Nov 25, 2015 at 2:05

0

You must log in to answer this question.

Browse other questions tagged .