Sha256: 09f52f9e1293c59bc2dc62c0ff4d49ff6a1891b216b39dc1e9395be3db3cd9d9

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 KB

Contents

# frozen_string_literal: true
module Hyrax
  module Admin
    class RepositoryGrowthPresenter
      def initialize(start_date, end_date)
        @x_min = start_date
        @x_max = end_date
        @date_format = ->(x) { x.strftime('%F') }
      end

      def as_json(*)
        works.to_a.zip(collections.to_a).map do |e|
          { y: e.first.first, works: e.first.last, collections: e.last.last }
        end
      end

      private

      def works
        Hyrax::Statistics::Works::OverTime.new(delta_x: 1,
                                               x_min: @x_min,
                                               x_max: @x_max,
                                               x_output: @date_format).points
      end

      def collections
        Hyrax::Statistics::Collections::OverTime.new(delta_x: 1,
                                                     x_min: @x_min,
                                                     x_max: @x_max,
                                                     x_output: @date_format).points
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hyrax-5.0.1 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-5.0.0 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-5.0.0.rc3 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-5.0.0.rc2 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-5.0.0.rc1 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.6.0 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0.rc3 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0.rc2 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0.rc1 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.5.0 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0.beta2 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.4.2 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-4.0.0.beta1 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.4.1 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.4.0 app/presenters/hyrax/admin/repository_growth_presenter.rb
hyrax-3.3.0 app/presenters/hyrax/admin/repository_growth_presenter.rb