Sha256: 611c498003d9fa289cec3abc5bc3a4f3e875349dc770a1112624f1e4223df4a3

Contents?: true

Size: 924 Bytes

Versions: 4

Compression:

Stored size: 924 Bytes

Contents

class ExampleDataMethods
  def self.issues_by_opened_at(properties)
    Issue.group_by_week(:opened_at).count.map { |date, count| [format_date(date), count] }
  end

  def self.issues_by_opened_at_and_repo(properties)
    Issue.group_by_week(:opened_at).joins(:repo).group('repos.full_name').count.map do |(date, name), count|
      [[format_date(date), name], count]
    end
  end

  def self.issues_by_opened_at_with_filters(properties)
    format = properties[:format]
    ui_filters = properties[:ui_filters]
    issues = Issue.group_by_week(:opened_at)
    issues = issues.where(state: ui_filters[:state]) if ui_filters.try(:[], :state).present?
    dates_issue_counts = issues.count.map { |date, count| [format_date(date), count] }
    return dates_issue_counts unless format == 'table'
    [['Date', 'Issue count']] + dates_issue_counts
  end

  def self.format_date(date)
    date.strftime('%b %-d, \'%y')
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
reports_kits-0.7.8 spec/support/example_data_methods.rb
reports_kits-0.7.7 spec/support/example_data_methods.rb
reports_kit-0.7.1 spec/support/example_data_methods.rb
reports_kit-0.7.0 spec/support/example_data_methods.rb