<commit_before>/**
 * Created by <NAME>
 * <EMAIL>
 * 14/07/2015.
 */

var pullRequestsURL = '/rest/inbox/latest/pull-requests?role=reviewer&start=0&limit=10&avatarSize=64&state=OPEN&order=oldest';
var myPullRequestsURL = '/rest/inbox/latest/pull-requests?role=author&start=0&limit=10&avatarSize=64&state=OPEN&order=oldest';
var whoAmI = '/plugins/servlet/applinks/whoami';

function host(uri) {
    var splitRegExp = /\/(\b|$)/g;
    if (!uri) return localStorage["_server"];
    return (_.compact(host().split(splitRegExp).concat(uri.split(splitRegExp)))).join('/');
}

var _listeners = {};

function me() {
    if (localStorage["_username"].length) {
        return localStorage["_username"];
    } else {
        return najax(host(whoAmI))
            .then(function (data) {
                localStorage["_username"] = data;
                return data;
            });
    }
}

function filterResult(data) {
    data = JSON.parse(data);

    // Open tasks:
    if (localStorage["_hide_pr_with_tasks"] == "true") {
        data.values = _.filter(data.values, function (pr) {
            return !(<commit_msg>Added function to get tasks of a pull request<commit_after>/**
 * Created by <NAME>
 * <EMAIL>
 * 14/07/2015.
 */

var pullRequestsURL = '/rest/inbox/latest/pull-requests?role=reviewer&start=0&limit=10&avatarSize=64&state=OPEN&order=oldest';
var myPullRequestsURL = '/rest/inbox/latest/pull-requests?role=author&start=0&limit=10&avatarSize=64&state=OPEN&order=oldest';
var whoAmI = '/plugins/servlet/applinks/whoami';

function host(uri) {
    var splitRegExp = /\/(\b|$)/g;
    if (!uri) return localStorage["_server"];
    return (_.compact(host().split(splitRegExp).concat(uri.split(splitRegExp)))).join('/');
}

var _listeners = {};

function me() {
    if (localStorage["_username"].length) {
        return localStorage["_username"];
    } else {
        return najax(host(whoAmI))
            .then(function (data) {
                localStorage["_username"] = data;
                return data;
            });
    }
}

function getTasks(pr) {
    var uri = host("/rest/api/latest" + pr["link"]["url"] + "/tasks?start=0&limit=5");
    var idx = 0;
    return najax(uri)
        .then(function (data) {
            return JSON.parse(data).values.map(function (task) {
                return ++idx + ". " + task.anchor.text.split(/\n/)[0];
            }).join('\n');
        });
}

function filterResult(data) {
    data = JSON.parse(data);

    // Open tasks:
    if (localStorage["_hide_pr_with_tasks"] == "true") {
        data.values = _.filter(data.values, function (pr) {
            return !(
{'fraction_non_alphanumeric': 0.17494270435446907, 'fraction_numerical': 0.015278838808250574, 'mean_word_length': 3.0230414746543777, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6240980', 'n_tokens_mistral': 892, 'n_tokens_neox': 863, 'n_words': 143}