Sha256: b40a536401dacac584cd61384a4125fde50b884afaffb97ae95a027693d9b804

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

module Hyrax
  class AdminStatsPresenter
    attr_reader :limit, :stats_filters

    def initialize(stats_filters, limit)
      @stats_filters = stats_filters
      @limit = limit
    end

    def start_date
      @start_date ||= Time.zone.parse(stats_filters[:start_date]).beginning_of_day if stats_filters[:start_date].present?
    end

    def end_date
      @end_date ||= Time.zone.parse(stats_filters[:end_date]).end_of_day if stats_filters[:end_date].present?
    end

    def depositors
      @depositors ||= Hyrax::Statistics::Depositors::Summary.new(start_date, end_date).depositors
    end

    def recent_users
      @recent_users ||= stats.recent_users
    end

    def active_users
      @active_users ||= Hyrax::Statistics::Works::ByDepositor.new(limit).query
    end

    def top_formats
      @top_formats ||= Hyrax::Statistics::FileSets::ByFormat.new(limit).query
    end

    def works_count
      @works_count ||= Hyrax::Statistics::Works::Count.new(start_date, end_date).by_permission
    end

    def date_filter_string
      if start_date.blank?
        "unfiltered"
      elsif end_date.blank?
        "#{start_date.to_date.to_formatted_s(:standard)} to #{Date.current.to_formatted_s(:standard)}"
      else
        "#{start_date.to_date.to_formatted_s(:standard)} to #{end_date.to_date.to_formatted_s(:standard)}"
      end
    end

    private

      def stats
        @stats ||= Hyrax::Statistics::SystemStats.new(limit, start_date, end_date)
      end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.1.0 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.5 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.4 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.3 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.2 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.1 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.0.rc2 app/presenters/hyrax/admin_stats_presenter.rb
hyrax-1.0.0.rc1 app/presenters/hyrax/admin_stats_presenter.rb
test_hyrax-0.0.1.alpha app/presenters/hyrax/admin_stats_presenter.rb