Class: Hyrax::Admin::Analytics::WorkReportsController

Inherits:
AnalyticsController
  • Object
show all
Includes:
BreadcrumbsForWorksAnalytics
Defined in:
app/controllers/hyrax/admin/analytics/work_reports_controller.rb

Instance Method Summary collapse

Methods included from BreadcrumbsForWorksAnalytics

#add_breadcrumb_for_action, #add_breadcrumb_for_controller, #mark_active_action

Methods included from Breadcrumbs

#add_breadcrumb_for_action, #add_breadcrumb_for_controller, #build_breadcrumbs, #default_trail, #trail_from_referer

Methods inherited from AnalyticsController

#date_range, #paginate, #set_date_range, #set_document, #set_months

Methods included from SingularSubresourceController

#find_work

Methods included from DenyAccessOverrideBehavior

#deny_access

Instance Method Details

#indexObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/hyrax/admin/analytics/work_reports_controller.rb', line 8

def index
  return unless Hyrax.config.analytics?

  @accessible_works ||= accessible_works
  @accessible_file_sets ||= accessible_file_sets
  @works_count = @accessible_works.count
  @top_works = paginate(top_works_list, rows: 10)
  @top_file_set_downloads = paginate(top_files_list, rows: 10)

  if current_user.ability.admin?
    @pageviews = Hyrax::Analytics.daily_events('work-view')
    @downloads = Hyrax::Analytics.daily_events('file-set-download')
  end

  respond_to do |format|
    format.html
    format.csv { export_data }
  end
end

#showObject


28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/hyrax/admin/analytics/work_reports_controller.rb', line 28

def show
  @pageviews = Hyrax::Analytics.daily_events_for_id(@document.id, 'work-view')
  @uniques = Hyrax::Analytics.unique_visitors_for_id(@document.id)
  @downloads = Hyrax::Analytics.daily_events_for_id(@document.id, 'file_set_in_work_download')
  @files = paginate(@document._source["file_set_ids_ssim"], rows: 5)
  respond_to do |format|
    format.html
    format.csv { export_data }
  end
end