Sha256: 48aee19c80ab417b228b86d9994839be915688b20b0cf6c34923e58804d983d0

Contents?: true

Size: 1.85 KB

Versions: 9

Compression:

Stored size: 1.85 KB

Contents

# frozen_string_literal: true

module Tractive
  class Info
    def print
      $logger.info result_hash.to_yaml
    end

    private

    def result_hash
      users = [
        Ticket.distinct.select(:reporter).select_map(:reporter),
        Ticket.distinct.select(:owner).select_map(:owner),
        TicketChange.distinct.select(:author).select_map(:author),
        TicketChange.distinct.select(:newvalue).where(field: "reporter").select_map(:newvalue),
        Revision.distinct.select(:author).select_map(:author),
        Report.distinct.select(:author).select_map(:author),
        Attachment.distinct.select(:author).select_map(:author)
      ].flatten.uniq.compact

      milestones = {}
      Milestone.each { |r| milestones[r.name] = r.to_hash }

      types       = Ticket.distinct.select(:type).select_map(:type).compact
      components  = Ticket.distinct.select(:component).select_map(:component).compact
      resolutions = Ticket.distinct.select(:resolution).select_map(:resolution).compact
      severity    = Ticket.distinct.select(:severity).select_map(:severity).compact
      priorities  = Ticket.distinct.select(:priority).select_map(:priority).compact
      tracstates  = Ticket.distinct.select(:status).select_map(:status).compact

      {
        "users" => Utilities.make_each_hash(users, %w[email name username]),
        "milestones" => milestones,
        "labels" => {
          "type" => Utilities.make_hash("type_", types),
          "resolution" => Utilities.make_hash("resolution_", resolutions),
          "component" => Utilities.make_each_hash(components, %w[name color], "component: "),
          "severity" => Utilities.make_each_hash(severity, %w[name color]),
          "priority" => Utilities.make_each_hash(priorities, %w[name color]),
          "tracstate" => Utilities.make_each_hash(tracstates, %w[name color])
        }
      }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tractive-1.0.14 lib/tractive/info.rb
tractive-1.0.13 lib/tractive/info.rb
tractive-1.0.12 lib/tractive/info.rb
tractive-1.0.11 lib/tractive/info.rb
tractive-1.0.10 lib/tractive/info.rb
tractive-1.0.9 lib/tractive/info.rb
tractive-1.0.8 lib/tractive/info.rb
tractive-1.0.7 lib/tractive/info.rb
tractive-1.0.6 lib/tractive/info.rb