Sha256: 08d4a85fbc0403c6880f1ab16209b41d034692fdaa730b388af580eba17e5431

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

module JiraIssues
  class JiraIssuesNavigator
    def initialize(issues)
      @issues = issues
    end

    def all
      @issues
    end

    def open
      @issues.select {|i| i[:status] == JiraWorkflow::OPEN}
    end

    def blocked
      @issues.select {|i| i[:status] == JiraWorkflow::BLOCKED}
    end

    def in_progress
      @issues.select {|i| i[:status] == JiraWorkflow::IN_PROGRESS}
    end

    def closed
      @issues.select {|i| i[:status] == JiraWorkflow::CLOSED}
    end

    def with_status(status: selected_status)
      @issues.select {|i| i[:status] == @issue_states[selected_status]}
    end

    def created_by_week
      @issues.map { |i| { key: i[:key], week_created: Date.parse(i[:created_date]).beginning_of_week}}.group_by { |x| x[:week_created]}.map{ |k,v| [k, v.count]  }.to_h.sort
    end

    def closed_by_week
      @issues.select{|i| !i[:closed_date].nil? }.map { |i| { key: i[:key], week_closed: Date.parse(i[:closed_date]).beginning_of_week}}.group_by { |x| x[:week_closed]}.map{ |k,v| [k, v.count]  }.to_h.sort
    end

    #aliases
    def todo
      open
    end

    def done
      closed
    end 

    def ip 
      in_progress
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jira-issues-0.0.1 lib/jira_issues/jira_issues_navigator.rb