var fetchWorkItems = function()

in js/work-items-analysis/work-items.js [15:36]


var fetchWorkItems = function(author, project, from, to) {
  // Generate a search string to find issues,
  // where at least one work item was added by `author` between `from` and `to`:
  var searchQuery = 'work author: ' + author.login + ' ';
  searchQuery += 'work date: ' + formatter(from) + ' .. ' + formatter(to);
  
  // Now we can traverse over these issues in a `project`
  // and choose the work items we need:
  var items = [];
  var issues = search.search(project, searchQuery);
  issues.forEach(function(issue) {
    issue.workItems.forEach(function(item) {
      if (item.author.login === author.login &&
        item.date >= from && item.date <= to) {
        items.push(item);
      }
    })
  });
  
  // Return the array:
  return items;
};