hyrax 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +1 -1
- data/.github/PULL_REQUEST_TEMPLATE.md +5 -0
- data/.rubocop.yml +8 -1
- data/README.md +3 -11
- data/app/actors/hyrax/actors/file_set_actor.rb +6 -1
- data/app/assets/javascripts/hyrax.js +1 -1
- data/app/assets/javascripts/hyrax/editor.es6 +8 -0
- data/app/assets/javascripts/hyrax/save_work/save_work_control.es6 +20 -1
- data/app/assets/javascripts/hyrax/save_work/uploaded_files.es6 +1 -0
- data/app/assets/stylesheets/hyrax/_breadcrumbs.scss +25 -0
- data/app/assets/stylesheets/hyrax/_collections.scss +6 -0
- data/app/assets/stylesheets/hyrax/_file-listing.scss +5 -0
- data/app/assets/stylesheets/hyrax/_file_upload.scss +14 -0
- data/app/assets/stylesheets/hyrax/_form-progress.scss +6 -0
- data/app/assets/stylesheets/hyrax/_hyrax.scss +1 -1
- data/app/assets/stylesheets/hyrax/_styles.scss +6 -0
- data/app/assets/stylesheets/hyrax/dashboard.scss +4 -5
- data/app/builders/hyrax/bootstrap_breadcrumbs_builder.rb +10 -4
- data/app/controllers/concerns/hyrax/admin/stats_behavior.rb +25 -1
- data/app/controllers/concerns/hyrax/breadcrumbs_for_collections.rb +6 -2
- data/app/controllers/concerns/hyrax/controller.rb +1 -1
- data/app/controllers/concerns/hyrax/deny_access_override_behavior.rb +1 -1
- data/app/controllers/concerns/hyrax/works_controller_behavior.rb +1 -1
- data/app/controllers/hyrax/admin/admin_sets_controller.rb +1 -1
- data/app/controllers/hyrax/dashboard/collections_controller.rb +2 -2
- data/app/controllers/hyrax/downloads_controller.rb +1 -1
- data/app/controllers/hyrax/featured_works_controller.rb +1 -5
- data/app/controllers/hyrax/homepage_controller.rb +1 -1
- data/app/controllers/hyrax/single_use_links_controller.rb +1 -1
- data/app/controllers/hyrax/transfers_controller.rb +1 -1
- data/app/controllers/hyrax/users_controller.rb +1 -0
- data/app/helpers/hyrax/citations_behaviors/publication_behavior.rb +2 -2
- data/app/helpers/hyrax/collections_helper.rb +1 -1
- data/app/helpers/hyrax/hyrax_helper_behavior.rb +2 -2
- data/app/jobs/characterize_job.rb +1 -1
- data/app/jobs/fixity_check_job.rb +1 -1
- data/app/jobs/import_url_job.rb +12 -1
- data/app/models/checksum_audit_log.rb +1 -1
- data/app/models/concerns/hyrax/ability.rb +1 -1
- data/app/models/hyrax/collection_type.rb +1 -1
- data/app/models/hyrax/operation.rb +4 -6
- data/app/models/hyrax/permission_template_access.rb +5 -5
- data/app/models/sipity/entity.rb +1 -1
- data/app/presenters/hyrax/admin_set_presenter.rb +9 -2
- data/app/presenters/hyrax/admin_stats_presenter.rb +52 -6
- data/app/presenters/hyrax/inspect_work_presenter.rb +1 -1
- data/app/presenters/hyrax/workflow_presenter.rb +1 -1
- data/app/search_builders/hyrax/dashboard/nested_collections_search_builder.rb +3 -5
- data/app/search_builders/hyrax/filter_suppressed_with_roles.rb +5 -1
- data/app/search_builders/hyrax/my/works_search_builder.rb +2 -1
- data/app/services/hyrax/collection_size_service.rb +12 -0
- data/app/services/hyrax/collections/nested_collection_query_service.rb +2 -2
- data/app/services/hyrax/graph_exporter.rb +6 -1
- data/app/services/hyrax/license_service.rb +1 -9
- data/app/services/hyrax/qa_select_service.rb +28 -0
- data/app/services/hyrax/rights_statement_service.rb +1 -1
- data/app/services/hyrax/tolerant_select_service.rb +23 -0
- data/app/services/hyrax/workflow/permission_query.rb +1 -1
- data/app/services/hyrax/workflow/sipity_actions_generator.rb +1 -1
- data/app/strategies/hyrax/strategies/yaml_strategy.rb +1 -1
- data/app/views/_logo.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +1 -1
- data/app/views/hyrax/admin/collection_types/index.html.erb +1 -1
- data/app/views/hyrax/admin/workflow_roles/index.html.erb +4 -2
- data/app/views/hyrax/admin/workflows/index.html.erb +1 -1
- data/app/views/hyrax/base/_form_files.html.erb +7 -7
- data/app/views/hyrax/base/_form_progress.html.erb +10 -5
- data/app/views/hyrax/base/_share_with.html.erb +3 -11
- data/app/views/hyrax/base/_show_actions.html.erb +1 -3
- data/app/views/hyrax/batch_edits/_check_all.html.erb +15 -7
- data/app/views/hyrax/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/_index_partials/_transfers.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_default_group.html.erb +7 -2
- data/app/views/hyrax/dashboard/collections/_edit_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/collections/_form.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_form_branding.html.erb +6 -6
- data/app/views/hyrax/dashboard/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/dashboard/collections/_show_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/collections/_show_add_items_actions.html.erb +1 -2
- data/app/views/hyrax/dashboard/sidebar/_repository_content.html.erb +1 -2
- data/app/views/hyrax/dashboard/works/_default_group.html.erb +1 -1
- data/app/views/hyrax/file_sets/_actions.html.erb +1 -1
- data/app/views/hyrax/file_sets/_form.html.erb +3 -3
- data/app/views/hyrax/file_sets/_permission.html.erb +2 -2
- data/app/views/hyrax/file_sets/_permission_form.html.erb +10 -10
- data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -4
- data/app/views/hyrax/file_sets/_single_use_links.html.erb +5 -0
- data/app/views/hyrax/file_sets/_versioning.html.erb +9 -7
- data/app/views/hyrax/file_sets/edit.html.erb +6 -6
- data/app/views/hyrax/file_sets/media_display/_audio.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_image.html.erb +1 -1
- data/app/views/hyrax/file_sets/media_display/_office_document.html.erb +0 -1
- data/app/views/hyrax/file_sets/media_display/_pdf.html.erb +0 -1
- data/app/views/hyrax/file_sets/media_display/_video.html.erb +1 -1
- data/app/views/hyrax/my/collections/_default_group.html.erb +8 -3
- data/app/views/hyrax/my/collections/_list_collections.html.erb +1 -1
- data/app/views/hyrax/my/works/_batch_actions.html.erb +1 -1
- data/app/views/hyrax/my/works/_tabs.html.erb +3 -3
- data/app/views/hyrax/single_use_links_viewer/show.html.erb +1 -1
- data/app/views/hyrax/uploads/_js_templates.html.erb +11 -11
- data/app/views/hyrax/uploads/_js_templates_branding.html.erb +2 -2
- data/app/views/layouts/_head_tag_content.html.erb +1 -1
- data/app/views/layouts/hyrax.html.erb +1 -1
- data/app/views/layouts/hyrax/dashboard.html.erb +1 -1
- data/app/views/records/edit_fields/_license.html.erb +1 -1
- data/app/views/records/edit_fields/_rights_statement.html.erb +2 -1
- data/config/features.rb +4 -0
- data/config/locales/hyrax.de.yml +1 -0
- data/config/locales/hyrax.en.yml +39 -1
- data/config/locales/hyrax.es.yml +1 -0
- data/config/locales/hyrax.fr.yml +1 -0
- data/config/locales/hyrax.it.yml +1 -0
- data/config/locales/hyrax.pt-BR.yml +1 -0
- data/config/locales/hyrax.zh.yml +1 -0
- data/hyrax.gemspec +5 -2
- data/lib/generators/hyrax/templates/mediated_deposit_workflow.json.erb +1 -0
- data/lib/hyrax.rb +7 -1
- data/lib/hyrax/arkivo/create_subscription_job.rb +1 -1
- data/lib/hyrax/redis_event_store.rb +1 -1
- data/lib/hyrax/resource_sync/change_list_writer.rb +2 -2
- data/lib/hyrax/version.rb +1 -1
- data/spec/actors/hyrax/actors/file_set_actor_spec.rb +1 -1
- data/spec/controllers/hyrax/admin/stats_controller_spec.rb +31 -1
- data/spec/controllers/hyrax/collections_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +2 -2
- data/spec/controllers/hyrax/generic_works_controller_spec.rb +19 -3
- data/spec/controllers/hyrax/homepage_controller_spec.rb +1 -1
- data/spec/controllers/hyrax/users_controller_spec.rb +58 -0
- data/spec/features/batch_create_spec.rb +1 -1
- data/spec/features/create_work_spec.rb +22 -2
- data/spec/features/dashboard/collection_spec.rb +3 -3
- data/spec/features/homepage_spec.rb +20 -4
- data/spec/javascripts/save_work_spec.js +50 -0
- data/spec/jobs/import_url_job_spec.rb +10 -8
- data/spec/lib/hyrax_spec.rb +9 -0
- data/spec/models/flipflop_spec.rb +8 -0
- data/spec/models/solr_document_spec.rb +2 -2
- data/spec/presenters/hyrax/admin_stats_presenter_spec.rb +73 -0
- data/spec/search_builders/hyrax/my/works_search_builder_spec.rb +0 -2
- data/spec/services/hyrax/graph_exporter_spec.rb +18 -0
- data/spec/services/hyrax/qa_select_service_spec.rb +40 -17
- data/spec/services/hyrax/tolerant_select_service_spec.rb +80 -0
- data/spec/support/fakes/fake_authority.rb +13 -0
- data/spec/support/logging_formatter.rb +1 -1
- data/spec/support/matchers/collection_type_property_matchers.rb +5 -5
- data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +11 -1
- data/spec/views/hyrax/file_sets/_show_actions.html.erb_spec.rb +0 -1
- data/spec/views/hyrax/file_sets/_single_use_links.html.erb_spec.rb +4 -0
- data/spec/views/hyrax/single_use_links_viewer/show.html.erb_spec.rb +0 -4
- data/template.rb +1 -1
- metadata +24 -11
- data/app/views/kaminari/blacklight_compact/_paginator.html.erb +0 -22
|
@@ -206,7 +206,7 @@ module Hyrax
|
|
|
206
206
|
|
|
207
207
|
def document_not_found!
|
|
208
208
|
doc = ::SolrDocument.find(params[:id])
|
|
209
|
-
raise WorkflowAuthorizationException if doc.suppressed?
|
|
209
|
+
raise WorkflowAuthorizationException if doc.suppressed? && current_ability.can?(:read, doc)
|
|
210
210
|
raise CanCan::AccessDenied.new(nil, :show)
|
|
211
211
|
end
|
|
212
212
|
|
|
@@ -25,7 +25,7 @@ module Hyrax
|
|
|
25
25
|
self.admin_set_create_service = AdminSetCreateService
|
|
26
26
|
|
|
27
27
|
def deny_adminset_access(exception)
|
|
28
|
-
if current_user
|
|
28
|
+
if current_user&.persisted?
|
|
29
29
|
redirect_to root_url, alert: exception.message
|
|
30
30
|
else
|
|
31
31
|
session['user_return_to'] = request.url
|
|
@@ -42,7 +42,7 @@ module Hyrax
|
|
|
42
42
|
def deny_collection_access(exception)
|
|
43
43
|
if exception.action == :edit
|
|
44
44
|
redirect_to(url_for(action: 'show'), alert: 'You do not have sufficient privileges to edit this document')
|
|
45
|
-
elsif current_user
|
|
45
|
+
elsif current_user&.persisted?
|
|
46
46
|
redirect_to root_url, alert: exception.message
|
|
47
47
|
else
|
|
48
48
|
session['user_return_to'] = request.url
|
|
@@ -242,7 +242,7 @@ module Hyrax
|
|
|
242
242
|
|
|
243
243
|
def remove_banner
|
|
244
244
|
banner_info = CollectionBrandingInfo.where(collection_id: @collection.id.to_s).where(role: "banner")
|
|
245
|
-
banner_info
|
|
245
|
+
banner_info&.delete_all
|
|
246
246
|
end
|
|
247
247
|
|
|
248
248
|
def update_logo_info(uploaded_file_id, alttext, linkurl)
|
|
@@ -16,11 +16,7 @@ module Hyrax
|
|
|
16
16
|
def destroy
|
|
17
17
|
authorize! :destroy, FeaturedWork
|
|
18
18
|
@featured_work = FeaturedWork.find_by(work_id: params[:id])
|
|
19
|
-
|
|
20
|
-
# Handle the case where a separate request may have already
|
|
21
|
-
# destroyed this work
|
|
22
|
-
@featured_work.destroy
|
|
23
|
-
end
|
|
19
|
+
@featured_work&.destroy
|
|
24
20
|
|
|
25
21
|
respond_to do |format|
|
|
26
22
|
format.json { head :no_content }
|
|
@@ -9,7 +9,7 @@ module Hyrax
|
|
|
9
9
|
rescue_from Hydra::AccessDenied, CanCan::AccessDenied, with: :deny_link_access
|
|
10
10
|
|
|
11
11
|
def deny_link_access(exception)
|
|
12
|
-
if current_user
|
|
12
|
+
if current_user&.persisted?
|
|
13
13
|
redirect_to main_app.root_url, alert: "You do not have sufficient privileges to create links to this document"
|
|
14
14
|
else
|
|
15
15
|
session["user_return_to"] = request.url
|
|
@@ -10,7 +10,7 @@ module Hyrax
|
|
|
10
10
|
# Catch permission errors
|
|
11
11
|
# TODO: Isn't this already handled?
|
|
12
12
|
rescue_from CanCan::AccessDenied do |exception|
|
|
13
|
-
if current_user
|
|
13
|
+
if current_user&.persisted?
|
|
14
14
|
redirect_to root_url, alert: exception.message
|
|
15
15
|
else
|
|
16
16
|
session["user_return_to"] = request.url
|
|
@@ -14,11 +14,11 @@ module Hyrax
|
|
|
14
14
|
|
|
15
15
|
# @param [Hyrax::WorkShowPresenter] work_presenter
|
|
16
16
|
def setup_pub_place(work_presenter)
|
|
17
|
-
work_presenter.based_near_label
|
|
17
|
+
work_presenter.based_near_label&.first
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def setup_pub_publisher(work)
|
|
21
|
-
work.publisher
|
|
21
|
+
work.publisher&.first
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def setup_pub_info(work, include_date = false)
|
|
@@ -11,7 +11,7 @@ module Hyrax
|
|
|
11
11
|
def render_collection_links(solr_doc)
|
|
12
12
|
collection_list = Hyrax::CollectionMemberService.run(solr_doc, controller.current_ability)
|
|
13
13
|
return if collection_list.empty?
|
|
14
|
-
links = collection_list.map { |collection| link_to collection.title_or_label, collection_path(collection.id) }
|
|
14
|
+
links = collection_list.map { |collection| link_to collection.title_or_label, hyrax.collection_path(collection.id) }
|
|
15
15
|
collection_links = []
|
|
16
16
|
links.each_with_index do |link, n|
|
|
17
17
|
collection_links << link
|
|
@@ -201,7 +201,7 @@ module Hyrax
|
|
|
201
201
|
# @param [Hash] options from blacklight helper_method invocation. Maps license URIs to links with labels.
|
|
202
202
|
# @return [ActiveSupport::SafeBuffer] license links, html_safe
|
|
203
203
|
def license_links(options)
|
|
204
|
-
service = Hyrax
|
|
204
|
+
service = Hyrax.config.license_service_class.new
|
|
205
205
|
to_sentence(options[:value].map { |right| link_to service.label(right), right })
|
|
206
206
|
end
|
|
207
207
|
|
|
@@ -209,7 +209,7 @@ module Hyrax
|
|
|
209
209
|
# @param [Hash] options from blacklight helper_method invocation. Maps rights statement URIs to links with labels.
|
|
210
210
|
# @return [ActiveSupport::SafeBuffer] rights statement links, html_safe
|
|
211
211
|
def rights_statement_links(options)
|
|
212
|
-
service = Hyrax
|
|
212
|
+
service = Hyrax.config.rights_statement_service_class.new
|
|
213
213
|
to_sentence(options[:value].map { |right| link_to service.label(right), right })
|
|
214
214
|
end
|
|
215
215
|
|
|
@@ -13,7 +13,7 @@ class CharacterizeJob < Hyrax::ApplicationJob
|
|
|
13
13
|
Rails.logger.debug "Ran characterization on #{file_set.characterization_proxy.id} (#{file_set.characterization_proxy.mime_type})"
|
|
14
14
|
file_set.characterization_proxy.save!
|
|
15
15
|
file_set.update_index
|
|
16
|
-
file_set.parent
|
|
16
|
+
file_set.parent&.in_collections&.each(&:update_index)
|
|
17
17
|
CreateDerivativesJob.perform_later(file_set, file_id, filepath)
|
|
18
18
|
end
|
|
19
19
|
end
|
data/app/jobs/import_url_job.rb
CHANGED
|
@@ -24,7 +24,7 @@ class ImportUrlJob < Hyrax::ApplicationJob
|
|
|
24
24
|
@file_set = file_set
|
|
25
25
|
@operation = operation
|
|
26
26
|
|
|
27
|
-
unless
|
|
27
|
+
unless can_retrieve?(uri)
|
|
28
28
|
send_error('Expired URL')
|
|
29
29
|
return false
|
|
30
30
|
end
|
|
@@ -44,6 +44,17 @@ class ImportUrlJob < Hyrax::ApplicationJob
|
|
|
44
44
|
|
|
45
45
|
private
|
|
46
46
|
|
|
47
|
+
# The previous strategy of using only a HEAD request to check the validity of a
|
|
48
|
+
# remote URL fails for Amazon S3 pre-signed URLs. S3 URLs are generated for a single
|
|
49
|
+
# verb only (in this case, GET), and will return a 403 Forbidden response if any
|
|
50
|
+
# other verb is used. The workaround is to issue a GET request instead, with a
|
|
51
|
+
# Range: header requesting only the first byte. The successful response status
|
|
52
|
+
# code is 206 instead of 200, but that is enough to satisfy the #success? method.
|
|
53
|
+
# @param uri [URI] the uri of the file to be downloaded
|
|
54
|
+
def can_retrieve?(uri)
|
|
55
|
+
HTTParty.get(uri, headers: { Range: 'bytes=0-0' }).success?
|
|
56
|
+
end
|
|
57
|
+
|
|
47
58
|
# Download file from uri, yields a block with a file in a temporary directory.
|
|
48
59
|
# It is important that the file on disk has the same file name as the URL,
|
|
49
60
|
# because when the file in added into Fedora the file name will get persisted in the
|
|
@@ -51,7 +51,7 @@ class ChecksumAuditLog < ActiveRecord::Base
|
|
|
51
51
|
|
|
52
52
|
0.upto(all_logs.length - 2).each do |i|
|
|
53
53
|
next if all_logs[i].failed?
|
|
54
|
-
next if i
|
|
54
|
+
next if i.positive? && all_logs[i - 1].failed?
|
|
55
55
|
next if all_logs[i + 1].failed?
|
|
56
56
|
|
|
57
57
|
all_logs[i].destroy!
|
|
@@ -75,7 +75,7 @@ module Hyrax
|
|
|
75
75
|
.joins(:permission_template)
|
|
76
76
|
.pluck('DISTINCT source_id')
|
|
77
77
|
query = "_query_:\"{!raw f=has_model_ssim}AdminSet\" AND {!terms f=id}#{ids.join(',')}"
|
|
78
|
-
ActiveFedora::SolrService.count(query)
|
|
78
|
+
ActiveFedora::SolrService.count(query).positive?
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# This overrides hydra-head, (and restores the method from blacklight-access-controls)
|
|
@@ -45,10 +45,8 @@ module Hyrax
|
|
|
45
45
|
def rollup_messages
|
|
46
46
|
[].tap do |messages|
|
|
47
47
|
messages << message if message.present?
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
messages << child_message if child_message.present?
|
|
51
|
-
end
|
|
48
|
+
children&.pluck(:message)&.uniq&.each do |child_message|
|
|
49
|
+
messages << child_message if child_message.present?
|
|
52
50
|
end
|
|
53
51
|
end
|
|
54
52
|
end
|
|
@@ -63,7 +61,7 @@ module Hyrax
|
|
|
63
61
|
def success!
|
|
64
62
|
run_callbacks :success do
|
|
65
63
|
update(status: SUCCESS)
|
|
66
|
-
parent
|
|
64
|
+
parent&.rollup_status
|
|
67
65
|
end
|
|
68
66
|
end
|
|
69
67
|
|
|
@@ -78,7 +76,7 @@ module Hyrax
|
|
|
78
76
|
def fail!(message = nil)
|
|
79
77
|
run_callbacks :failure do
|
|
80
78
|
update(status: FAILURE, message: message)
|
|
81
|
-
parent
|
|
79
|
+
parent&.rollup_status
|
|
82
80
|
end
|
|
83
81
|
end
|
|
84
82
|
|
|
@@ -11,12 +11,12 @@ module Hyrax
|
|
|
11
11
|
scope: [:agent_id, :agent_type, :permission_template_id]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
VIEW = 'view'
|
|
15
|
-
DEPOSIT = 'deposit'
|
|
16
|
-
MANAGE = 'manage'
|
|
14
|
+
VIEW = 'view'
|
|
15
|
+
DEPOSIT = 'deposit'
|
|
16
|
+
MANAGE = 'manage'
|
|
17
17
|
|
|
18
|
-
GROUP = 'group'
|
|
19
|
-
USER = 'user'
|
|
18
|
+
GROUP = 'group'
|
|
19
|
+
USER = 'user'
|
|
20
20
|
|
|
21
21
|
enum(
|
|
22
22
|
access: {
|
data/app/models/sipity/entity.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
module Hyrax
|
|
2
2
|
class AdminSetPresenter < CollectionPresenter
|
|
3
|
+
##
|
|
4
|
+
# @return [Boolean] true if there are items
|
|
5
|
+
def any_items?
|
|
6
|
+
total_items.positive?
|
|
7
|
+
end
|
|
8
|
+
|
|
3
9
|
def total_items
|
|
4
10
|
ActiveFedora::SolrService.count("{!field f=isPartOf_ssim}#{id}")
|
|
5
11
|
end
|
|
@@ -10,13 +16,14 @@ module Hyrax
|
|
|
10
16
|
|
|
11
17
|
# AdminSet cannot be deleted if default set or non-empty
|
|
12
18
|
def disable_delete?
|
|
13
|
-
AdminSet.default_set?(id) ||
|
|
19
|
+
AdminSet.default_set?(id) || any_items?
|
|
14
20
|
end
|
|
15
21
|
|
|
16
22
|
# Message to display if deletion is disabled
|
|
17
23
|
def disabled_message
|
|
18
24
|
return I18n.t('hyrax.admin.admin_sets.delete.error_default_set') if AdminSet.default_set?(id)
|
|
19
|
-
|
|
25
|
+
|
|
26
|
+
I18n.t('hyrax.admin.admin_sets.delete.error_not_empty') if any_items?
|
|
20
27
|
end
|
|
21
28
|
|
|
22
29
|
def collection_type
|
|
@@ -2,10 +2,49 @@ module Hyrax
|
|
|
2
2
|
class AdminStatsPresenter
|
|
3
3
|
attr_reader :limit, :stats_filters
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
##
|
|
6
|
+
# @!attribute [rw] by_depositor
|
|
7
|
+
# @return [#query]
|
|
8
|
+
# @!attribute [rw] by_format
|
|
9
|
+
# @return [#query]
|
|
10
|
+
# @!attribute [rw] depositor_summary
|
|
11
|
+
# @return [#depositors]
|
|
12
|
+
# @!attribute [rw] system_stats
|
|
13
|
+
# @return [#recent_users]
|
|
14
|
+
# @!attribute [rw] works_counter
|
|
15
|
+
# @return [#by_permission]
|
|
16
|
+
attr_accessor :by_depositor, :by_format, :depositor_summary, :system_stats,
|
|
17
|
+
:works_counter
|
|
18
|
+
|
|
19
|
+
# Long parameter lists (especially optional) are preferred to hard-coded
|
|
20
|
+
# dependencies. Further refactors may be desirable.
|
|
21
|
+
#
|
|
22
|
+
# rubocop:disable Metrics/ParameterLists
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# @param stats_filters [Hash<Symbol, Object>]
|
|
26
|
+
# @param limit [FixNum]
|
|
27
|
+
# @param by_depositor [#query]
|
|
28
|
+
# @param by_format [#query]
|
|
29
|
+
# @param depositor_summary [#depositors]
|
|
30
|
+
# @param system_stats [#recent_users]
|
|
31
|
+
# @param works_counter [#by_permission]
|
|
32
|
+
def initialize(stats_filters, limit,
|
|
33
|
+
by_depositor: Hyrax::Statistics::Works::ByDepositor,
|
|
34
|
+
by_format: Hyrax::Statistics::FileSets::ByFormat,
|
|
35
|
+
depositor_summary: Hyrax::Statistics::Depositors::Summary,
|
|
36
|
+
system_stats: Hyrax::Statistics::SystemStats,
|
|
37
|
+
works_counter: Hyrax::Statistics::Works::Count)
|
|
6
38
|
@stats_filters = stats_filters
|
|
7
39
|
@limit = limit
|
|
40
|
+
|
|
41
|
+
self.by_depositor = by_depositor
|
|
42
|
+
self.by_format = by_format
|
|
43
|
+
self.depositor_summary = depositor_summary
|
|
44
|
+
self.system_stats = system_stats
|
|
45
|
+
self.works_counter = works_counter
|
|
8
46
|
end
|
|
47
|
+
# rubocop:enable Metrics/ParameterLists
|
|
9
48
|
|
|
10
49
|
def start_date
|
|
11
50
|
@start_date ||= extract_date_from_stats_filters(key: :start_date, as_of: :beginning_of_day)
|
|
@@ -26,29 +65,36 @@ module Hyrax
|
|
|
26
65
|
|
|
27
66
|
# @see Hyrax::Statistics::Depositors::Summary
|
|
28
67
|
def depositors
|
|
29
|
-
@depositors ||=
|
|
68
|
+
@depositors ||=
|
|
69
|
+
depositor_summary.depositors(start_date: start_date, end_date: end_date)
|
|
30
70
|
end
|
|
31
71
|
|
|
32
72
|
# @see Hyrax::Statistics::SystemStats.recent_users
|
|
33
73
|
def recent_users
|
|
34
|
-
@recent_users ||=
|
|
74
|
+
@recent_users ||=
|
|
75
|
+
system_stats.recent_users(limit: limit,
|
|
76
|
+
start_date: start_date,
|
|
77
|
+
end_date: end_date)
|
|
35
78
|
end
|
|
36
79
|
|
|
37
80
|
# @see Hyrax::Statistics::Works::ByDepositor
|
|
38
81
|
def active_users
|
|
39
|
-
@active_users ||=
|
|
82
|
+
@active_users ||= by_depositor.query(limit: limit)
|
|
40
83
|
end
|
|
41
84
|
|
|
42
85
|
# @see Hyrax::Statistics::FileSets::ByFormat
|
|
43
86
|
def top_formats
|
|
44
|
-
@top_formats ||=
|
|
87
|
+
@top_formats ||= by_format.query(limit: limit)
|
|
45
88
|
end
|
|
46
89
|
|
|
47
90
|
# @see Hyrax::Statistics::Works::Count
|
|
48
91
|
def works_count
|
|
49
|
-
@works_count ||=
|
|
92
|
+
@works_count ||=
|
|
93
|
+
works_counter.by_permission(start_date: start_date, end_date: end_date)
|
|
50
94
|
end
|
|
51
95
|
|
|
96
|
+
##
|
|
97
|
+
# @return [String]
|
|
52
98
|
def date_filter_string
|
|
53
99
|
if start_date.blank?
|
|
54
100
|
"unfiltered"
|
|
@@ -43,7 +43,7 @@ module Hyrax
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def workflow_comments
|
|
46
|
-
return [] unless sipity_entity
|
|
46
|
+
return [] unless sipity_entity&.comments&.any?
|
|
47
47
|
sipity_entity.comments.map do |comment|
|
|
48
48
|
{ comment: comment.comment, created_at: comment.created_at }
|
|
49
49
|
end
|
|
@@ -100,11 +100,9 @@ module Hyrax
|
|
|
100
100
|
array_to_exclude += @nesting_attributes.ancestors unless @nesting_attributes.ancestors.nil?
|
|
101
101
|
# build a unique string containing all of Collection F's pathnames and ancestors
|
|
102
102
|
exclude_list = ""
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
exclude_list += element.to_s
|
|
107
|
-
end
|
|
103
|
+
array_to_exclude&.uniq&.each do |element|
|
|
104
|
+
exclude_list += ' ' unless exclude_list.empty?
|
|
105
|
+
exclude_list += element.to_s
|
|
108
106
|
end
|
|
109
107
|
# Using a !lucene query allows us to get items which match any individual element
|
|
110
108
|
# from the list. Building the query via the AF builder created a !field query which
|
|
@@ -31,7 +31,11 @@ module Hyrax
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def depositor?
|
|
34
|
-
current_work[DepositSearchBuilder.depositor_field]
|
|
34
|
+
depositors = current_work[DepositSearchBuilder.depositor_field]
|
|
35
|
+
|
|
36
|
+
return false if depositors.nil?
|
|
37
|
+
|
|
38
|
+
depositors.first == current_ability.current_user.user_key
|
|
35
39
|
end
|
|
36
40
|
end
|
|
37
41
|
end
|