Sha256: 9386f33b40821436469d97e0a6efe2b2c5e58d301dd889c57ef5e31fd93dc6bb

Contents?: true

Size: 684 Bytes

Versions: 8

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Admin
    class UserActivityPresenter
      def initialize
        @x_min = 90.days.ago.beginning_of_day
        @date_format = ->(x) { x.strftime('%b %-d') }
      end

      def as_json(*)
        new_users.to_a.zip(returning_users.to_a).map do |e|
          { y: e.first.first, a: e.first.last, b: e.last.try(:last) }
        end
      end

      private

      def new_users
        Hyrax::Statistics::Users::OverTime.new(x_min: @x_min,
                                               x_output: @date_format).points
      end

      # TODO: using google analytics
      def returning_users
        []
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hyrax-3.2.0 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.1.0 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.2 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.1 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.0 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.0.pre.rc4 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.0.pre.rc3 app/presenters/hyrax/admin/user_activity_presenter.rb
hyrax-3.0.0.pre.rc2 app/presenters/hyrax/admin/user_activity_presenter.rb