19

Sorry if this seems to be a lazy question, but I'm not that well versed with the SE Data Explorer.

Is it possible to apply a query, to see the actual ratio of close votes issued vs the resulted closed questions for a particular (my) account? (and if so, how should the basic skeleton of the SQL statement look like of course)


More background, why I'm asking:

I'm ending up almost every day being onside at SO, having all of my close votes spent.
I wan't to systematically review them, and see, how they actually did work or not.
I'm only human, as (hopefully) all of us around here. I'm going to make wrong decisions sometimes, and want to improve, or even to correct them as much as possible.

I couldn't see a straightforward way to see my performance on validly closed/deleted questions, or how to setup a good query for such review regarding the points stated above.

I'd like to alleviate the massive close vote queue as much as possible.


As for this came up in a comment

Do 10k+ users actually see the deleted questions when going into their profile under votes -> closure? It is strange since it says closure (deleted) for non-deleted questions in my profile. @Artjom B.

Yes, I'm able to see what actually was deleted along with my close votes: enter image description here

That's seems to be a +10k privilege.

5
  • 1
    You have pretty high rep ; it would seem that you can figure such a query out, no ? Sep 26, 2014 at 19:51
  • 2
    MSE dupe: How to see the correctness of close/reopen votes?. In short, you can get the answer, but it is skewed due to deleted questions, that are not include the data.
    – user000001
    Sep 26, 2014 at 19:52
  • @user000001 See my comment at @Servy's answer please. Sep 26, 2014 at 19:57
  • 1
    @Coffee Looks like I can't out of the box now. I well know how to use SQL, but I don't know about SE's data model details :P ... Sep 26, 2014 at 19:59
  • 2
    Would this really measure your performance or correctness, even if it weren't for the deleted questions problem? How many questions do you think you've correctly voted to close that are still open just because there haven't been 4 other people who've bothered to look? Probably a lot; that's what the massive close queue means, isn't it? So, how do you distinguish between those and the ones where you voted wrong, especially given that the latter is probably a lot less common?
    – abarnert
    Sep 29, 2014 at 3:20

2 Answers 2

3

You can go to your profile under votes > closure and look through. If you only want a list of questions where you think you did an error, I wrote a CasperJS script to scrape those votes. In the end two csv files and a json file is written to the same directory.

I would classify erroneous votes as !closed && !deleted && successful where successful means that (deleted) text is present. As animuson♦ writes:

The "(deleted)" text under a close vote means that the close vote itself was successful (the question got closed), aged away, or was otherwise cleared. If the text is not present, the close vote is still active.

I need a little help, because I don't know what class a row has when the question is deleted. Right now, I assume it contains deleted-, but that might be wrong since I'm not a 10k+ user.

Full script:

// Run as: casperjs --cookies-file=cookies.txt SE_get_close_votes.js
//    to skip logging in the next time or simply: casperjs SE_get_close_votes.js
// Don't forget to input your credentials
// The login is not perfect, so it might fail. Just try again.

var casper = require('casper').create({
        viewportSize: {
            width: 1280,
            height: 800
        },
        pageSettings: {
            userAgent: "PhantomJS (Close Vote Scraper)"
        }
    }),
    fs = require("fs"),
    x = require('casper').selectXPath,
    i = 0,
    account = {
        email: "",
        password: ""
    },
    sites = [
        "http://stackoverflow.com"
    ],
    loginLink = x("//a[text()='log in' and @class='login-link']"),
    loginSpan = x("//span[text()='Log in using Stack Exchange']"),
    reputationSpan = "span.reputation",
    profileLink = "a.profile-me",
    profileVotesTab = x("//div[@id='tabs']/a[normalize-space(text())='votes']"),
    profileVotesTabClosure = x("//div[contains(@class,'subtabs')]/a[normalize-space(text())='closure']"), 
    profileVotesTabClosureTabClosureText = x("//td/span[text()='closure']"), 
    historyTableNext = "a>span.page-numbers.next", 
    logFile = "action_close_votes.log",
    scrapeFile = "close_votes.json",
    scrapeFileCSV = "close_votes.csv",
    failedFile = "failed_votes.csv",
    scrapeList = [],
    showMessages = false;

if (account.email == "" || account.password == "") {
    console.log("You didn't set login credentials. Please edit this file.");
    casper.exit();
}

casper.on("error", function(msg, backtrace){
    this.echo(msg);
    require("utils").dump(backtrace);
    this.echo("Title: " + this.getTitle());
    capture(true);
});

casper.on("remote.message", function(msg){
    if (!showMessages) return;
    this.echo("remote.msg: " + msg);
});

casper.on("resource.error", function(resourceError){
    if (!showMessages) return;
    this.echo("res.err: " + JSON.stringify(resourceError));
});

casper.on("page.error", function(pageErr){
    if (!showMessages) return;
    this.echo("page.err: " + JSON.stringify(pageErr));
});

function capture(err){
    if (err){
        casper.capture("cap_err.png");
        fs.write("cap_err.html", casper.getHTML());
    } else {
        casper.capture("cap_"+i+".png");
        fs.write("cap_"+(i++)+".html", casper.getHTML());
    }
}

function thenCapture(){
    casper.then(function(){
        capture();
    });
}

function log(site, msg){
    var str = (new Date()).toISOString() + " - " + site + " - " + msg + "\r\n";
    casper.echo(str);
    //fs.write(logFile, str, "a");
}

function navigateAndScrape(site){
    this.thenClick(profileLink);
    this.waitForSelector(profileVotesTab);
    this.thenClick(profileVotesTab);
    this.waitForSelector(profileVotesTabClosure);
    this.thenClick(profileVotesTabClosure);
    this.waitForSelector(profileVotesTabClosureTabClosureText); // maybe delete too?
    scrapeClosurePage.call(this, 1, site);
}

function scrapeClosurePage(page, site) {
    this.then(function(){
        this.echo("page " + page);
    });
    this.waitFor(function check(){
        return this.fetchText("span.page-numbers.current") === ""+page;
    }, function then(){
        var newArticles = this.evaluate(function(){
            function endsWith(str, suffix) {
                // from https://stackoverflow.com/a/2548133
                return str.indexOf(suffix, str.length - suffix.length) !== -1;
            }
            var trList = document.querySelectorAll("table.history-table > tbody > tr:nth-child(2n-1)");
            return Array.prototype.map.call(trList, function(tr){
                var dateString = tr.querySelector("td > .date, td > .date > .date_brick").title,
                    question = tr.querySelector("a.question-hyperlink"),
                    title = question.innerText;
                return {
                    url: question.href,
                    title: title,
                    dateString: dateString,
                    timestamp: (new Date(dateString)).getTime(),
                    isClosed: endsWith(title, "[closed]") || 
                        endsWith(title, "[duplicate]") || 
                        endsWith(title, "[on hold]") || 
                        endsWith(title, "[migrated]"),
                    isDeleted: tr.className.indexOf("deleted-") !== -1, // TODO: just assuming, check this!
                    isSuccessful: tr.children[1].children.length === 2 // "(delete)" is present
                };
            });
        });
        scrapeList = scrapeList.concat(newArticles);
    });
    this.then(function(){
        if (this.visible(historyTableNext)) {
            this.click(historyTableNext);
            scrapeClosurePage.call(this, page+1, site);
        }
    });
}

casper.start();

casper.each(sites, function(self, site){
    self.then(function(){
        this.echo("Opening: " + site);
        log(site, "opening");
    });
    self.thenOpen(site, function(){
        if (this.visible(loginLink)) {
            log(site, "do login");
            capture();
            this.thenClick(loginLink);
            this.then(function(){
                log(site, "login page opened");
                capture();
                if (this.visible(reputationSpan)) {
                    // SE inferred the account without login
                    navigateAndScrape.call(this, site);
                    return;
                }
                this.click(loginSpan);
                this.waitWhileVisible("#forgot-password", function(){
                    log(site, "login form opened");
                    capture();
                    this.fillSelectors("form#se-login-form", {
                        "input[name='email']": account.email,
                        "input[name='password']": account.password,
                    }, true);
                    this.wait(1000);
                    thenCapture();
                    navigateAndScrape.call(this, site);
                });
            });
        } else if (this.visible(reputationSpan)){
            log(site, "already logged in");
            capture();
            navigateAndScrape.call(this, site);
        } else {
            log(site, "Warning: no log in link found");
        }
    });
});

casper.run(function(){
    var separator = ";",
        failedVote = "Title" + separator + "URL" + separator + "Date" + separator + "closed" + separator + "deleted" + separator + "success\n",
        totalVote = failedVote,
        failedLength = 0;
    scrapeList.forEach(function(article){
        var row = article.title + separator + 
                article.url + separator + 
                article.dateString + separator + 
                article.isClosed + separator + 
                article.isDeleted + separator + 
                article.isSuccessful + "\n";
        if (!article.isClosed && !article.isDeleted && article.isSuccessful) {
            failedLength++;
            failedVote += row;
        }
        totalVote += row;
    });
    console.log("total length", scrapeList.length);
    console.log("failed length", failedLength);
    fs.write(failedFile, failedVote);
    fs.write(scrapeFileCSV, totalVote);
    fs.write(scrapeFile, JSON.stringify(scrapeList));
    log("none", "done");
    this.exit();
});

My erroneous votes are 32/222, but since I'm mostly on and , most of the votes probably just timed out.

1
  • 1
    Your assumption is correct. The class is deleted-answer, which oddly also gets applied to deleted questions. There is no deleted-question class.
    – animuson StaffMod
    Sep 29, 2014 at 22:37
8

The data exporer doesn't include deleted questions, so while you could do it, the data is going to be extremely skewed, likely beyond usability. The questions that you voted to close that actually got closed are far more likely to have been deleted than questions that you voted to close that didn't end up being closed.

8
  • Well, deleted questions should count in to make sense for me. I'd like to know about hmm good performance, such deleted questions are still in my scope of interest to get this ratio. Sep 26, 2014 at 19:52
  • 1
    Do 10k+ users actually see the deleted questions when going into their profile under votes -> closure? It is strange since it says closure (deleted) for non-deleted questions in my profile.
    – Artjom B.
    Sep 27, 2014 at 7:00
  • @ArtjomB. See my updates please. Sep 27, 2014 at 18:34
  • 2
    @ArtjomB. 10k users recently started seeing deleted questions in that list, yes. The "(deleted)" text under a close vote means that the close vote itself was successful (the question got closed), aged away, or was otherwise cleared. If the text is not present, the close vote is still active.
    – animuson StaffMod
    Sep 27, 2014 at 21:09
  • 3
    @animuson Why not show the corresponding text like on hold , closed, deleted etc to avoid the confusion..? will that be an overkill..?!
    – T J
    Sep 29, 2014 at 8:02
  • 1
    @TJ It is - at the end of the title where it is normally shown
    – animuson StaffMod
    Sep 29, 2014 at 12:26
  • @animuson I was speaking of the votes section in profile, where it shows "deleted" even if the question is on hold...
    – T J
    Sep 29, 2014 at 15:56
  • 1
    @TJ Right, the term deleted there is referring to the vote, not the question. A better term there would be "cleared", which is actually the term that is used in our moderator timeline. A vote is not always cleared because the question got closed, though. It can also be cleared if it ages away, or the user retracts their vote. As well, if the question gets reopened, the vote would still be in a cleared state. -- If the question is deleted, it shows with a red background. If it's closed for any reason, that is shown at the end of the title.
    – animuson StaffMod
    Sep 29, 2014 at 22:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .