From 03e8a6215404a8b515a704930851b4631b759ba5 Mon Sep 17 00:00:00 2001 From: Tom Lianza Date: Mon, 27 May 2013 08:40:53 -0700 Subject: [PATCH] When rendering the 'recently logged' area, omit items that already appear elsewhere in the non-icebox portions of the report. ie. items that are already scheduled. --- default.rb | 22 +++++++++++++++------- models/story.rb | 8 ++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/default.rb b/default.rb index 85fddef..0c428c8 100755 --- a/default.rb +++ b/default.rb @@ -93,6 +93,10 @@ @backlog_stories = Array.new @icebox = Array.new + # Used to weed stories out of the list to-be prioritized because + # we know they're already on the schedule. + @scheduled_story_ids = Set.new + params[:projects].split(',').uniq.each do |project| #Work done in last iteration @@ -105,6 +109,7 @@ @done_stories << story @done_points += story.estimate end + @scheduled_story_ids.add(story.story_id) end end @@ -119,22 +124,25 @@ @current_stories << story @current_points += story.estimate end + @scheduled_story_ids.add(story.story_id) end end - + + #Grab the rest of the backlog + if include_backlog + @backlog_stories = parse_stories_from_iterations(iterations(project, params[:api_key], 3, 1)) + @backlog_stories.each { |story| @scheduled_story_ids.add(story.story_id) } + end + #Grab the recently logged stories begin doc = Nokogiri::HTML(created_since(@start_date, project, params[:api_key], 'state:unscheduled')) doc.xpath('//stories//story').each do |s| - @recently_logged_stories << Story.new.from_xml(s) + story = Story.new.from_xml(s) + @recently_logged_stories << story unless @scheduled_story_ids.include?(story.story_id) end end - #Grab the rest of the backlog - if include_backlog - @backlog_stories = parse_stories_from_iterations(iterations(project, params[:api_key], 3, 1)) - end - #Grab the icebox if(include_icebox) doc = Nokogiri::HTML(icebox(project, params[:api_key])) diff --git a/models/story.rb b/models/story.rb index ed8707d..f52d974 100755 --- a/models/story.rb +++ b/models/story.rb @@ -1,11 +1,11 @@ class Story -attr_reader :id, :title, :description, :url, :accepted_at, :requested_by, :owned_by, :created_at, :story_type, :current_state, :estimate, :updated_at, :labels +attr_reader :story_id, :title, :description, :url, :accepted_at, :requested_by, :owned_by, :created_at, :story_type, :current_state, :estimate, :updated_at, :labels attr_accessor :estimated_date # Builds a story given an XML node from pivotal tracker def from_xml(node) - @id = node.xpath('id')[0].content + @story_id = node.xpath('id')[0].content @title = node.xpath('name')[0].content @description = node.xpath('description')[0].content unless node.xpath('description')[0].nil? @url = node.xpath('url')[0].content @@ -61,12 +61,12 @@ def self.top_labels(story_array, limit=3) story_array.each { |story| if story.labels.nil? @labels['z_uncategorized'] = Array.new unless @labels.has_key?('z_uncategorized') - @labels['z_uncategorized'] << story.id + @labels['z_uncategorized'] << story.story_id @label_weights['z_uncategorized'] +=1 else story.labels.each do |l| @labels[l] = Array.new unless @labels.has_key?(l) - @labels[l] << story.id + @labels[l] << story.story_id @label_weights[l] += 1.to_f/story.labels.count end end