Project

General

Profile

Actions

Highlight my backlog

// ==UserScript==
// @name         Highlight my redmine backlog
// @namespace    https://dev.arvados.org/projects/arvados/wiki/Highlight_my_backlog
// @version      0.1
// @description  Highlights issues assigned to you in redmine Backlogs view.
// @author       Tom Clegg
// @match        https://dev.arvados.org/rb/master_backlog/*
// @grant        none
// ==/UserScript==

$.ajax('/my/account', {success: function(data, _, _) {
    var key = $('#api-access-key',data).text();
    var url = '/issues.json?assigned_to_id=me&limit=100';
    var ajaxopts = {
        dataType: 'json',
        headers: {'X-Redmine-API-Key': key},
        success: dopage
    };
    $.ajax(url, ajaxopts);
    function dopage(data, _, _) {
        for (var i=0; i<data.issues.length; i++) {
            $('#story_'+data.issues[i].id).css({
                //background:'#faa',
                'font-weight':'bold'
            });
        }
        if (data.total_count > data.offset + data.limit) {
            $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts);
        }
    }
}});

puts in parens the total point count you have for each sprint

// ==UserScript==
// @name         Highlight my redmine backlog
// @namespace    https://dev.arvados.org/projects/arvados/wiki/Highlight_my_backlog
// @version      0.2
// @description  Highlights issues assigned to you in redmine Backlogs view and
//               puts in parens the total point count you have for each sprint.
// @author       Tom Clegg, Abram Connelly
// @match        https://dev.arvados.org/rb/master_backlog/*
// @grant        none
// ==/UserScript==

$.ajax('/my/api_key', {success: function(data, _, _) {
    var key = $('div.box pre',data).text();
    var url = '/issues.json?set_filter=1&f[]=assigned_to_id&op[assigned_to_id]=%3d&v[assigned_to_id][]=me&limit=100';
    var ajaxopts = {
        dataType: 'json',
        headers: {'X-Redmine-API-Key': key},
        success: dopage,
    };
    $.ajax(url, ajaxopts);
    function dopage(data, _, _) {

        var my_sprint_info = {};

        for (var i=0; i<data.issues.length; i++) {

            if ("fixed_version" in data.issues[i]) {
              var sprint_id = data.issues[i].fixed_version.id;
              var sprint_name = data.issues[i].fixed_version.name;
              if (!(sprint_id in my_sprint_info)) {
                  my_sprint_info[sprint_id]={"story_points" : 0, "sprint_id" : sprint_id, "sprint_name" : sprint_name };
              }
              if ("story_points" in data.issues[i]) {
                my_sprint_info[sprint_id].story_points += data.issues[i].story_points;
              }
            }

            $('#story_'+data.issues[i].id).css({
                color:'#fff',
                background:'#444',
                'font-weight':'bold',
            });
        }

        if (data.total_count > data.offset + data.limit) {
            $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts);
        }

        for (var sprint_id in my_sprint_info) {
            var cur_pnt = $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text();
            cur_pnt += " (" + my_sprint_info[sprint_id].story_points +")";
            $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text(cur_pnt);
        }
    }
}});

color each user a different color

The user ids are hardcoded in.
Thanks to Abram and http://stackoverflow.com/questions/13977046/using-anonymous-function-in-javascript-for-loops .

// ==UserScript==
// @name         Highlight my redmine backlog
// @namespace    https://arvados.org/projects/arvados/wiki/Highlight_my_backlog
// @version      0.1c
// @description  Highlights issues assigned to hardcoded set of  users in redmine Backlogs view and
//               puts in parens the total point count everyone have for each sprint. (point ct runs off screen right now)
// @author       Tom Clegg, Abram Connelly, Nancy Ouyang
// @match        https://dev.arvados.org/rb/master_backlog/*
// @grant        none
// ==/UserScript==

$.ajax('/my/account', {success: function(data, _, _) {
    //    var sguthrie = 184;
    //    var nouyang = 235;
    //    var jli = 303;
    //    var aconnelly = 99;
    //    var azaranek = 8;
    //    var szaranek = 326;
    //ROYGBV
    var usercolors = {184:'rgba(255,0,0, 0.4)', 235:'rgba(255,153,0, 0.4)', 303:'rgba(255,255,0, 0.4)', 99:'rgba(0,255,0, 0.4)', 8:'rgba(0,255,255, 0.4)', 326:'rgba(128,0,128, 0.4)'};

    for ( var usercolor in usercolors ) {
        (function(usercolor) {
            //console.log(usercolors[usercolor]);
            var key = $('#api-access-key',data).text();
            var url = '/issues.json?assigned_to_id=' + usercolor + '&limit=50';
            var ajaxopts = {
                dataType: 'json',
                headers: {'X-Redmine-API-Key': key},
                success: dopage
            };
            $.ajax(url, ajaxopts);

            function dopage(data, _, _) {
                //console.log(usercolor, usercolors[usercolor]);
                var my_sprint_info = {};

                for (var i=0; i<data.issues.length; i++) {

                    if ("fixed_version" in data.issues[i]) {
                        var sprint_id = data.issues[i].fixed_version.id;
                        var sprint_name = data.issues[i].fixed_version.name;
                        if (!(sprint_id in my_sprint_info)) {
                            my_sprint_info[sprint_id]={"story_points" : 0, "sprint_id" : sprint_id, "sprint_name" : sprint_name };
                        }
                        if ("story_points" in data.issues[i]) {
                            my_sprint_info[sprint_id].story_points += data.issues[i].story_points;
                        }
                    }

                    $('#story_'+data.issues[i].id).css({
                        //'background':'#F49C54', //orange
                        'background':usercolors[usercolor],
                        'font-family':'URW Bookman L, serif',
                        'font-size':'1.2em',
                    });
                }

                if (data.total_count > data.offset + data.limit) {
                    $.ajax(url + '&offset=' + (data.offset + data.limit), ajaxopts);
                }

                for (var sprint_id in my_sprint_info) {
                    var cur_pnt = $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text();
                    cur_pnt += " (" + my_sprint_info[sprint_id].story_points +")";
                    $("#sprint_" + sprint_id).children(".fff-right").children(".velocity").text(cur_pnt);
                }
            }
        } )(usercolor);
    }
}});

Useful stuff

Links

Example of changing the background color and the font (in short, use 'font-family' not 'font')

'background':'#F49C54', //orange
'font-family':'URW Bookman L, serif',
'font-size':'1.2em',

Possible extensions

It would be nice to color each element in the backlog page by who owns it. It would also be nice to be able to add up point totals per sprint for each person as this is a common task.

Here is an API call that can get the process started:

function dopage(data) { console.log(data); }
var ajaxopts = { dataType: 'json', headers: {'X-Redmine-API-Key' : key}, success: dopage };
var url0 = "/issues.json?project_id=39&limit=100&offset=0";
var url1 = "/issues.json?project_id=39&limit=100&offset=100";
$.ajax(url0,ajaxopts);
$.ajax(url1,ajaxopts);

(39 is the lightning project id).

The idea being, collect points by sprint name/id for each person seen (stored in a hash). Color each story appropriate as referenced in the 'assigned_to' structure. Not sure where to put the point totals.

Updated by Tom Clegg about 7 years ago ยท 12 revisions