sprinter.js
function formatIssues(format, issues) {
    var formattedIssues
      , partition
      , superIssues
      , singletonIssues
      , removedSubtasks = [];
    if (format == 'network') {
        formattedIssues = {
            supers: []
          , singletons: []
          , all: issues
        };
        partition = _.partition(issues, function(issue) {
            return _.find(issue.labels, function(label) {
                return label.name == 'super';
            });
        });
        superIssues = partition.shift();
        singletonIssues = partition.shift();
        _.each(superIssues, function(superIssue) {
            var subTaskNumbers = extractSuperIssueSubTaskNumbers(superIssue);
            superIssue.subtasks = _.filter(singletonIssues, function(issue) {
                var isSubtask = _.contains(subTaskNumbers, issue.number);
                if (isSubtask) {
                    removedSubtasks.push(issue.number);
                }
                return isSubtask;
            });
        });
        formattedIssues.supers = superIssues;
        _.each(singletonIssues, function(issue) {
            if (! _.contains(removedSubtasks, issue.number)) {
                formattedIssues.singletons.push(issue);
            }
        });
    } else {
        formattedIssues = issues;
    }
    return formattedIssues;
}
function formatIssues(format, issues) {
    var formattedIssues
      , partition
      , superIssues
      , singletonIssues
      , removedSubtasks = [];
    if (format == 'network') {
        formattedIssues = {
            supers: []
          , singletons: []
          , all: issues
        };
        partition = _.partition(issues, function(issue) {
            return _.find(issue.labels, function(label) {
                return label.name == 'super';
            });
        });
        superIssues = partition.shift();
        singletonIssues = partition.shift();
        _.each(superIssues, function(superIssue) {
            var subTaskNumbers = extractSuperIssueSubTaskNumbers(superIssue);
            superIssue.subtasks = _.filter(singletonIssues, function(issue) {
                var isSubtask = _.contains(subTaskNumbers, issue.number);
                if (isSubtask) {
                    removedSubtasks.push(issue.number);
                }
                return isSubtask;
            });
        });
        formattedIssues.supers = superIssues;
        _.each(singletonIssues, function(issue) {
            if (! _.contains(removedSubtasks, issue.number)) {
                formattedIssues.singletons.push(issue);
            }
        });
    } else {
        formattedIssues = issues;
    }
    return formattedIssues;
}
function formatIssues ( format , issues ) { var formattedIssues , partition , superIssues , singletonIssues , removedSubtasks = [ ] ; if ( format == 'network' ) { formattedIssues = { supers : [ ] , singletons : [ ] , all : issues } ; partition = _ . partition ( issues , function ( issue ) { return _ . find ( issue . labels , function ( label ) { return label . name == 'super' ; } ) ; } ) ; superIssues = partition . shift ( ) ; singletonIssues = partition . shift ( ) ; _ . each ( superIssues , function ( superIssue ) { var subTaskNumbers = extractSuperIssueSubTaskNumbers ( superIssue ) ; superIssue . subtasks = _ . filter ( singletonIssues , function ( issue ) { var isSubtask = _ . contains ( subTaskNumbers , issue . number ) ; if ( isSubtask ) { removedSubtasks . push ( issue . number ) ; } return isSubtask ; } ) ; } ) ; formattedIssues . supers = superIssues ; _ . each ( singletonIssues , function ( issue ) { if ( ! _ . contains ( removedSubtasks , issue . number ) ) { formattedIssues . singletons . push ( issue ) ; } } ) ; } else { formattedIssues = issues ; } return formattedIssues ; }
Takes an array of issue objects and presents them differently depending on
'format'. The only valid option now is "network", which groups super issue
subtasks into a "subtasks" array on the super issue object.
@param format {string} 'network' or null
@param issues {array}
@returns {object} with 'supers' array, 'singletons' array and 'size' for
total number of issues in all.
Takes an array of issue objects and presents them differently depending on format . The only valid option now is network which groups super issue subtasks into a subtasks array on the super issue object .