hyrax 2.0.0.beta4 → 2.0.0.beta5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_fixme.yml +0 -1
  3. data/.travis.yml +4 -3
  4. data/README.md +3 -3
  5. data/app/actors/hyrax/actors/create_with_remote_files_actor.rb +22 -0
  6. data/app/actors/hyrax/actors/file_set_actor.rb +4 -0
  7. data/app/actors/hyrax/actors/transfer_request_actor.rb +23 -0
  8. data/app/assets/javascripts/hyrax/autocomplete/default.es6 +2 -1
  9. data/app/assets/stylesheets/hyrax/_file_manager.scss +3 -0
  10. data/app/controllers/hyrax/dashboard/collections_controller.rb +0 -1
  11. data/app/controllers/hyrax/my_controller.rb +1 -1
  12. data/app/forms/hyrax/forms/work_form.rb +5 -4
  13. data/app/helpers/hyrax/content_block_helper_behavior.rb +2 -2
  14. data/app/helpers/hyrax/hyrax_helper_behavior.rb +0 -7
  15. data/app/indexers/hyrax/indexes_workflow.rb +1 -1
  16. data/app/models/admin_set.rb +1 -1
  17. data/app/models/concerns/hyrax/basic_metadata.rb +1 -1
  18. data/app/models/concerns/hyrax/in_admin_set.rb +1 -1
  19. data/app/models/concerns/hyrax/proxy_deposit.rb +0 -8
  20. data/app/models/concerns/hyrax/solr_document_behavior.rb +0 -11
  21. data/app/models/concerns/hyrax/user.rb +3 -3
  22. data/app/models/hyrax/orcid_validator.rb +6 -1
  23. data/app/services/hyrax/admin_set_create_service.rb +0 -1
  24. data/app/services/hyrax/default_middleware_stack.rb +1 -0
  25. data/app/services/hyrax/statistics/depositors/summary.rb +5 -1
  26. data/app/services/hyrax/statistics/over_time.rb +5 -1
  27. data/app/services/hyrax/statistics/query_service.rb +55 -0
  28. data/app/services/hyrax/statistics/works/count.rb +1 -1
  29. data/app/services/hyrax/workflow/status_list_service.rb +1 -1
  30. data/app/views/hyrax/base/_form.html.erb +2 -1
  31. data/app/views/hyrax/base/_form_files.html.erb +0 -2
  32. data/app/views/hyrax/base/_form_progress.html.erb +1 -1
  33. data/app/views/hyrax/base/_form_visibility_error.html.erb +3 -0
  34. data/app/views/hyrax/base/_show_actions.html.erb +1 -1
  35. data/app/views/hyrax/dashboard/collections/_show_actions.html.erb +1 -1
  36. data/app/views/hyrax/dashboard/profiles/_edit_primary.html.erb +4 -1
  37. data/app/views/hyrax/dashboard/show_user.html.erb +3 -1
  38. data/app/views/hyrax/file_sets/_show_actions.html.erb +1 -1
  39. data/app/views/hyrax/homepage/_recent_document.html.erb +1 -1
  40. data/config/locales/hyrax.de.yml +9 -8
  41. data/hyrax.gemspec +2 -2
  42. data/lib/generators/hyrax/config_generator.rb +14 -16
  43. data/lib/generators/hyrax/templates/config/{hyrax.rb → initializers/hyrax.rb} +21 -0
  44. data/lib/generators/hyrax/templates/config/{mini_magick.rb → initializers/mini_magick.rb} +0 -0
  45. data/lib/generators/hyrax/templates/config/{redis_config.rb → initializers/redis_config.rb} +0 -0
  46. data/lib/hyrax.rb +2 -1
  47. data/lib/hyrax/configuration.rb +17 -10
  48. data/lib/hyrax/controlled_vocabularies.rb +9 -0
  49. data/{app/controlled_vocabularies → lib}/hyrax/controlled_vocabularies/location.rb +0 -0
  50. data/lib/hyrax/version.rb +1 -1
  51. data/spec/actors/hyrax/actors/create_with_remote_files_actor_spec.rb +36 -0
  52. data/spec/actors/hyrax/actors/file_set_actor_spec.rb +5 -1
  53. data/spec/actors/hyrax/actors/transfer_request_actor_spec.rb +43 -0
  54. data/spec/controllers/hyrax/admin/admin_sets_controller_spec.rb +1 -1
  55. data/spec/controllers/hyrax/api/items_controller_spec.rb +4 -4
  56. data/spec/controllers/hyrax/batch_edits_controller_spec.rb +3 -6
  57. data/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +87 -68
  58. data/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +5 -5
  59. data/spec/controllers/hyrax/file_sets_controller_spec.rb +7 -19
  60. data/spec/controllers/hyrax/fixity_checks_controller_spec.rb +1 -1
  61. data/spec/controllers/hyrax/generic_works_controller_spec.rb +1 -3
  62. data/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb +2 -4
  63. data/spec/factories/admin_sets.rb +0 -4
  64. data/spec/forms/hyrax/forms/work_form_spec.rb +41 -0
  65. data/spec/helpers/hyrax/content_block_helper_spec.rb +6 -0
  66. data/spec/helpers/hyrax_helper_spec.rb +0 -13
  67. data/spec/indexers/hyrax/generic_work_indexer_spec.rb +4 -1
  68. data/spec/javascripts/autocomplete_spec.js.coffee +39 -4
  69. data/spec/jobs/fixity_check_job_spec.rb +1 -2
  70. data/spec/lib/hyrax/configuration_spec.rb +4 -2
  71. data/spec/models/admin_set_spec.rb +0 -24
  72. data/spec/models/collection_spec.rb +0 -13
  73. data/spec/models/file_set_spec.rb +0 -17
  74. data/spec/models/generic_work_spec.rb +0 -11
  75. data/spec/models/solr_document_spec.rb +0 -32
  76. data/spec/models/user_spec.rb +20 -5
  77. data/spec/presenters/hyrax/file_usage_spec.rb +3 -7
  78. data/spec/services/hyrax/admin_set_create_service_spec.rb +2 -2
  79. data/spec/services/hyrax/admin_set_service_spec.rb +2 -2
  80. data/spec/services/hyrax/change_content_depositor_service_spec.rb +2 -6
  81. data/spec/services/hyrax/collections_service_spec.rb +1 -1
  82. data/spec/services/hyrax/default_middleware_stack_spec.rb +1 -0
  83. data/spec/services/hyrax/import_url_failure_service_spec.rb +1 -3
  84. data/spec/services/hyrax/persist_directly_contained_output_file_service_spec.rb +2 -1
  85. data/spec/services/hyrax/repository_fixity_check_service_spec.rb +1 -3
  86. data/spec/services/hyrax/{query_service_spec.rb → statistics/query_service_spec.rb} +5 -3
  87. data/spec/services/hyrax/versioning_service_spec.rb +2 -5
  88. data/spec/services/hyrax/work_query_service_spec.rb +1 -1
  89. data/spec/services/hyrax/workflow/status_list_service_spec.rb +7 -2
  90. data/spec/views/hyrax/admin/admin_sets/_show_document_list_row.html.erb_spec.rb +1 -4
  91. data/spec/views/hyrax/base/_form.html.erb_spec.rb +4 -11
  92. data/spec/views/hyrax/base/_form_progress.html.erb_spec.rb +14 -0
  93. data/spec/views/hyrax/collections/_show_document_list_row.html.erb_spec.rb +1 -3
  94. data/spec/views/hyrax/dashboard/collections/_show_document_list_row.html.erb_spec.rb +1 -3
  95. data/spec/views/hyrax/dashboard/profiles/edit.html.erb_spec.rb +24 -0
  96. data/spec/views/hyrax/dashboard/show_user_spec.rb +24 -0
  97. data/template.rb +1 -1
  98. metadata +18 -13
  99. data/app/services/hyrax/query_service.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dce0351f90dab9f83f599f852a0d848cc1a0639d
4
- data.tar.gz: 9f887777b8a1c9e0dd4e79396d65e84c45500e51
3
+ metadata.gz: 66a42f4f84b9b456857d5b5262a5b424eafe3814
4
+ data.tar.gz: 7b78a9ea6a2d7c304ee49da60282e66489520849
5
5
  SHA512:
6
- metadata.gz: abc04fb4e67beb79d5e7db29b49ee4b86aa0b0ba1b9287a3f61cc82ef26b115978a716ae1e11f7f4f17f6b19b4dad75f79ff343fcab917f9a1792e151448c058
7
- data.tar.gz: 262d51922326d67a601f5f16f28f8f9db4d1a79d1c47e65df1160441962595d862f67a417961e9b4cce1e3a821eba04accc51a53d2fa1a17c79482567fae7ca6
6
+ metadata.gz: f5cb54d0f8f526b1aa2f6decb4247831a2fc695afb3e3e8cabfc153847ac6029a05d899296070258e4736a397ff37b010ff442b9a961e1672598887f97d34974
7
+ data.tar.gz: a7dc23482e9c9362d08dd4845824f6bd5b37ffee27d504799c2ea74e56a0ff4fe0f0950b39a8b60b866748d11b7ff14d9b2bfdcc0da52d1c2a78987d8ea72b2e
data/.rubocop_fixme.yml CHANGED
@@ -159,7 +159,6 @@ RSpec/LetBeforeExamples:
159
159
  - 'spec/forms/hyrax/forms/collection_form_spec.rb'
160
160
  - 'spec/presenters/hyrax/collection_presenter_spec.rb'
161
161
  - 'spec/presenters/hyrax/trophy_presenter_spec.rb'
162
- - 'spec/services/hyrax/query_service_spec.rb'
163
162
  - 'spec/services/hyrax/workflow/action_taken_service_spec.rb'
164
163
  - 'spec/services/hyrax/workflow/notification_service_spec.rb'
165
164
 
data/.travis.yml CHANGED
@@ -13,18 +13,19 @@ before_install:
13
13
  - google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
14
14
 
15
15
  rvm:
16
- - 2.4.1
16
+ - 2.4.2
17
17
 
18
18
  env:
19
19
  global:
20
20
  - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
21
+ - ENGINE_CART_RAILS_OPTIONS='--skip-git --skip-bundle --skip-listen --skip-spring --skip-yarn --skip-keeps --skip-action-cable --skip-coffee --skip-puma --skip-test'
21
22
  # Travis should check every minor version in a range of supported versions, because
22
23
  # rails does not follow sem-ver conventions, see http://guides.rubyonrails.org/maintenance_policy.html
23
24
  # It should be sufficient to test only the latest of the patch versions for a minor version, they
24
25
  # should be compatible across patch versions (only bug fixes are released in patch versions).
25
26
  matrix:
26
- - "RAILS_VERSION=5.0.5"
27
- - "RAILS_VERSION=5.1.2"
27
+ - "RAILS_VERSION=5.1.4"
28
+ - "RAILS_VERSION=5.0.6"
28
29
 
29
30
  services:
30
31
  - redis-server
data/README.md CHANGED
@@ -63,7 +63,7 @@ The Samvera community is here to help. Please see our [support guide](./.github/
63
63
  # Getting started
64
64
 
65
65
  This document contains instructions specific to setting up an app with __Hyrax
66
- v2.0.0.beta4__. If you are looking for instructions on installing a different
66
+ v2.0.0.beta5__. If you are looking for instructions on installing a different
67
67
  version, be sure to select the appropriate branch or tag from the drop-down
68
68
  menu above.
69
69
 
@@ -144,7 +144,7 @@ Hyrax requires Rails 5. We recommend the latest Rails 5.0 release.
144
144
 
145
145
  ```
146
146
  # If you don't already have Rails at your disposal...
147
- gem install rails -v 5.0.5
147
+ gem install rails -v 5.0.6
148
148
  ```
149
149
 
150
150
  ### JavaScript runtime
@@ -160,7 +160,7 @@ NOTE: The steps need to be done in order to create a new Hyrax based app.
160
160
  Generate a new Rails application using the template.
161
161
 
162
162
  ```
163
- rails _5.0.5_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.beta4/template.rb
163
+ rails _5.0.6_ new my_app -m https://raw.githubusercontent.com/samvera/hyrax/v2.0.0.beta5/template.rb
164
164
  ```
165
165
 
166
166
  Generating a new Rails application using Hyrax's template above takes cares of a number of steps for you, including:
@@ -18,12 +18,34 @@ module Hyrax
18
18
 
19
19
  private
20
20
 
21
+ def whitelisted_ingest_dirs
22
+ Hyrax.config.whitelisted_ingest_dirs
23
+ end
24
+
25
+ def validate_remote_url(url)
26
+ uri = URI.parse(URI.encode(url))
27
+ if uri.scheme == 'file'
28
+ path = File.absolute_path(URI.decode(uri.path))
29
+ whitelisted_ingest_dirs.any? do |dir|
30
+ path.start_with?(dir) && path.length > dir.length
31
+ end
32
+ else
33
+ # TODO: It might be a good idea to validate other URLs as well.
34
+ # The server can probably access URLs the user can't.
35
+ true
36
+ end
37
+ end
38
+
21
39
  # @param [HashWithIndifferentAccess] remote_files
22
40
  # @return [TrueClass]
23
41
  def attach_files(env, remote_files)
24
42
  return true unless remote_files
25
43
  remote_files.each do |file_info|
26
44
  next if file_info.blank? || file_info[:url].blank?
45
+ unless validate_remote_url(file_info[:url])
46
+ Rails.logger.error "User #{env.user.user_key} attempted to ingest file from url #{file_info[:url]}, which doesn't pass validation"
47
+ return false
48
+ end
27
49
  create_file_from_url(env, file_info[:url], file_info[:file_name])
28
50
  end
29
51
  true
@@ -28,6 +28,10 @@ module Hyrax
28
28
  # hand. Do this because we don't have the underlying UploadedFile instance
29
29
  file_actor = build_file_actor(relation)
30
30
  file_actor.ingest_file(wrapper!(file: file, relation: relation))
31
+ # Copy visibility and permissions from parent (work) to
32
+ # FileSets even if they come in from BrowseEverything
33
+ VisibilityCopyJob.perform_later(file_set.parent)
34
+ InheritPermissionsJob.perform_later(file_set.parent)
31
35
  else
32
36
  IngestJob.perform_later(wrapper!(file: file, relation: relation))
33
37
  end
@@ -0,0 +1,23 @@
1
+ module Hyrax
2
+ module Actors
3
+ # Notify the provided owner that their proxy wants to make a
4
+ # deposit on their behalf
5
+ class TransferRequestActor < AbstractActor
6
+ # @param [Hyrax::Actors::Environment] env
7
+ # @return [Boolean] true if create was successful
8
+ def create(env)
9
+ next_actor.create(env) && create_proxy_deposit_request(env)
10
+ end
11
+
12
+ private
13
+
14
+ def create_proxy_deposit_request(env)
15
+ proxy = env.curation_concern.on_behalf_of
16
+ return true if proxy.blank?
17
+ ContentDepositorChangeEventJob.perform_later(env.curation_concern,
18
+ ::User.find_by_user_key(proxy))
19
+ true
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,7 +1,8 @@
1
1
  export default class Default {
2
2
  constructor(element, url) {
3
3
  this.url = url;
4
- element.autocomplete(this.options(element));
4
+ if (this.url !== undefined)
5
+ element.autocomplete(this.options(element))
5
6
  }
6
7
 
7
8
  options(element) {
@@ -69,6 +69,9 @@
69
69
  .member_resource_options {
70
70
  @extend .col-xs-12;
71
71
  float: none;
72
+ span.radio:first-of-type {
73
+ margin-top: 50px;
74
+ }
72
75
  input[type=radio] {
73
76
  margin-left: 1px;
74
77
  }
@@ -46,7 +46,6 @@ module Hyrax
46
46
  # The search builder to find the collections' members
47
47
  self.member_search_builder_class = Hyrax::CollectionMemberSearchBuilder
48
48
 
49
- # load_and_authorize_resource except: [:index, :show, :create], instance_name: :collection
50
49
  load_and_authorize_resource except: [:index, :create], instance_name: :collection
51
50
 
52
51
  before_action :ensure_admin!, only: :index # index for All Collections; see also Hyrax::My::CollectionsController #index for My Collections
@@ -22,7 +22,7 @@ module Hyrax
22
22
  configure_facets
23
23
 
24
24
  before_action :authenticate_user!
25
- before_action :enforce_show_permissions, only: :show
25
+ load_and_authorize_resource only: :show, instance_name: :collection
26
26
 
27
27
  # include the render_check_all view helper method
28
28
  helper Hyrax::BatchEditsHelper
@@ -13,9 +13,10 @@ module Hyrax
13
13
  delegate :work_members_attributes=, to: :model
14
14
  delegate :human_readable_type, :open_access?, :authenticated_only_access?,
15
15
  :open_access_with_embargo_release_date?, :private_access?,
16
- :embargo_release_date, :lease_expiration_date, :member_ids,
16
+ :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo,
17
+ :visibility_during_lease, :lease_expiration_date, :visibility_after_lease,
17
18
  :visibility, :in_works_ids, :depositor, :on_behalf_of, :permissions,
18
- :member_of_collection_ids, to: :model
19
+ :member_ids, :member_of_collection_ids, to: :model
19
20
 
20
21
  attr_reader :agreement_accepted
21
22
 
@@ -104,10 +105,10 @@ module Hyrax
104
105
  CollectionOptionsPresenter.new(service).select_options(:edit)
105
106
  end
106
107
 
107
- # Select collection(s) based on passed-in params
108
+ # Select collection(s) based on passed-in params and existing memberships.
108
109
  # @return [Array] a list of collection identifiers
109
110
  def member_of_collections(collection_ids)
110
- Array.wrap(collection_ids)
111
+ (member_of_collection_ids + Array.wrap(collection_ids)).uniq
111
112
  end
112
113
 
113
114
  # Sanitize the parameters coming from the form. This ensures that the client
@@ -1,12 +1,12 @@
1
1
  module Hyrax
2
2
  module ContentBlockHelperBehavior
3
3
  def displayable_content_block(content_block, **options)
4
- return if content_block.value.blank?
4
+ return unless display_content_block? content_block
5
5
  content_tag :div, raw(content_block.value), options
6
6
  end
7
7
 
8
8
  def display_content_block?(content_block)
9
- content_block.value.present?
9
+ content_block.present? && content_block.value.present?
10
10
  end
11
11
  end
12
12
  end
@@ -47,13 +47,6 @@ module Hyrax
47
47
  "https://www.zotero.org/users/#{zotero_user_id}"
48
48
  end
49
49
 
50
- # Only Chrome supports this
51
- # @return [Boolean]
52
- # @todo Replace uses with more granular client-side detection (as jQuery-fileuploader already does)
53
- def browser_supports_directory_upload?
54
- user_agent.include? 'Chrome'
55
- end
56
-
57
50
  # @param [User] user
58
51
  def render_notifications(user:)
59
52
  mailbox = UserMailbox.new(user)
@@ -26,7 +26,7 @@ module Hyrax
26
26
  return unless object.persisted?
27
27
  entity = PowerConverter.convert_to_sipity_entity(object)
28
28
  return if entity.nil?
29
- solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.name}-#{role}" }
29
+ solr_document[workflow_role_field] = workflow_roles(entity).map { |role| "#{entity.workflow.permission_template.admin_set_id}-#{entity.workflow.name}-#{role}" }
30
30
  solr_document[workflow_state_name_field] = entity.workflow_state.name if entity.workflow_state
31
31
  end
32
32
 
@@ -40,7 +40,7 @@ class AdminSet < ActiveFedora::Base
40
40
  end
41
41
 
42
42
  has_many :members,
43
- predicate: ::RDF::Vocab::DC.isPartOf,
43
+ predicate: Hyrax.config.admin_set_predicate,
44
44
  class_name: 'ActiveFedora::Base'
45
45
 
46
46
  before_destroy :check_if_not_default_set, :check_if_empty
@@ -26,7 +26,7 @@ module Hyrax
26
26
  property :subject, predicate: ::RDF::Vocab::DC11.subject
27
27
  property :language, predicate: ::RDF::Vocab::DC11.language
28
28
  property :identifier, predicate: ::RDF::Vocab::DC.identifier
29
- property :based_near, predicate: ::RDF::Vocab::FOAF.based_near, class_name: ControlledVocabularies::Location
29
+ property :based_near, predicate: ::RDF::Vocab::FOAF.based_near, class_name: Hyrax::ControlledVocabularies::Location
30
30
  property :related_url, predicate: ::RDF::RDFS.seeAlso
31
31
  property :bibliographic_citation, predicate: ::RDF::Vocab::DC.bibliographicCitation
32
32
  property :source, predicate: ::RDF::Vocab::DC.source
@@ -3,7 +3,7 @@ module Hyrax
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- belongs_to :admin_set, predicate: ::RDF::Vocab::DC.isPartOf
6
+ belongs_to :admin_set, predicate: Hyrax.config.admin_set_predicate
7
7
  end
8
8
 
9
9
  def active_workflow
@@ -11,14 +11,6 @@ module Hyrax
11
11
  property :on_behalf_of, predicate: ::RDF::URI.new('http://scholarsphere.psu.edu/ns#onBehalfOf'), multiple: false do |index|
12
12
  index.as :symbol
13
13
  end
14
-
15
- after_create :create_transfer_request
16
- end
17
-
18
- def create_transfer_request
19
- return if on_behalf_of.blank?
20
- ContentDepositorChangeEventJob.perform_later(self,
21
- ::User.find_by_user_key(on_behalf_of))
22
14
  end
23
15
 
24
16
  def request_transfer_to(target)
@@ -99,16 +99,5 @@ module Hyrax
99
99
  Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
100
100
  end
101
101
  end
102
-
103
- # Find the solr documents for the collections this object belongs to
104
- # TODO: can we remove this method now?
105
- def collections
106
- return @collections if @collections
107
- query = 'id:' + collection_ids.map { |id| '"' + id + '"' }.join(' OR ')
108
- result = Blacklight.default_index.connection.select(params: { q: query })
109
- @collections = result['response']['docs'].map do |hash|
110
- ::SolrDocument.new(hash)
111
- end
112
- end
113
102
  end
114
103
  end
@@ -96,9 +96,9 @@ module Hyrax::User
96
96
  # 1. validation has already flagged the ORCID as invalid
97
97
  # 2. the orcid field is blank
98
98
  # 3. the orcid is already in its normalized form
99
- return if errors[:orcid].first.present? || orcid.blank? || orcid.starts_with?('http://orcid.org/')
100
- bare_orcid = Hyrax::OrcidValidator.match(orcid).string
101
- self.orcid = "http://orcid.org/#{bare_orcid}"
99
+ return if errors[:orcid].first.present? || orcid.blank? || orcid.starts_with?('https://orcid.org/')
100
+ bare_orcid = Hyrax::OrcidValidator.match(orcid)
101
+ self.orcid = "https://orcid.org/#{bare_orcid}"
102
102
  end
103
103
 
104
104
  # Format the json for select2 which requires just an id and a field called text.
@@ -6,7 +6,12 @@ module Hyrax
6
6
  end
7
7
 
8
8
  def self.match(string)
9
- /\d{4}-\d{4}-\d{4}-\d{3}[\dX]/.match(string)
9
+ Regexp.new(orcid_regex).match(string) { |m| m[:orcid] }
10
10
  end
11
+
12
+ def self.orcid_regex
13
+ '^(?<prefix>https?://orcid.org/)?(?<orcid>\d{4}-\d{4}-\d{4}-\d{3}[\dX])/?$'
14
+ end
15
+ private_class_method :orcid_regex
11
16
  end
12
17
  end
@@ -53,7 +53,6 @@ module Hyrax
53
53
  # Creates an admin set, setting the creator and the default access controls.
54
54
  # @return [TrueClass, FalseClass] true if it was successful
55
55
  def create
56
- admin_set.read_groups = ['public']
57
56
  admin_set.edit_groups = [admin_group_name]
58
57
  admin_set.creator = [creating_user.user_key] if creating_user
59
58
  admin_set.save.tap do |result|
@@ -13,6 +13,7 @@ module Hyrax
13
13
  middleware.use Hyrax::Actors::AttachMembersActor
14
14
  middleware.use Hyrax::Actors::ApplyOrderActor
15
15
  middleware.use Hyrax::Actors::InterpretVisibilityActor
16
+ middleware.use Hyrax::Actors::TransferRequestActor
16
17
  middleware.use Hyrax::Actors::DefaultAdminSetActor
17
18
  middleware.use Hyrax::Actors::ApplyPermissionTemplateActor
18
19
  middleware.use Hyrax::Actors::CleanupFileSetsActor
@@ -55,7 +55,11 @@ module Hyrax
55
55
  end
56
56
 
57
57
  def date_query
58
- Hyrax::QueryService.new.build_date_query(start_dt, end_dt) if start_dt.present?
58
+ query_service.build_date_query(start_dt, end_dt) if start_dt.present?
59
+ end
60
+
61
+ def query_service
62
+ Hyrax::Statistics::QueryService.new
59
63
  end
60
64
  end
61
65
  end
@@ -35,7 +35,11 @@ module Hyrax
35
35
  end
36
36
 
37
37
  def query(min, max)
38
- QueryService.new.build_date_query(min, max)
38
+ query_service.build_date_query(min, max)
39
+ end
40
+
41
+ def query_service
42
+ Hyrax::Statistics::QueryService.new
39
43
  end
40
44
 
41
45
  # How many points are in this data set
@@ -0,0 +1,55 @@
1
+ module Hyrax
2
+ module Statistics
3
+ class QueryService
4
+ # query to find works created during the time range
5
+ # @param [DateTime] start_datetime starting date time for range query
6
+ # @param [DateTime] end_datetime ending date time for range query
7
+ def find_by_date_created(start_datetime, end_datetime = nil)
8
+ return [] if start_datetime.blank? # no date just return nothing
9
+ relation.where(build_date_query(start_datetime, end_datetime))
10
+ end
11
+
12
+ def find_registered_in_date_range(start_datetime, end_datetime = nil)
13
+ find_by_date_created(start_datetime, end_datetime).merge(where_registered)
14
+ end
15
+
16
+ def find_public_in_date_range(start_datetime, end_datetime = nil)
17
+ find_by_date_created(start_datetime, end_datetime).merge(where_public)
18
+ end
19
+
20
+ def where_public
21
+ where_access_is 'public'
22
+ end
23
+
24
+ def where_registered
25
+ where_access_is 'registered'
26
+ end
27
+
28
+ def build_date_query(start_datetime, end_datetime)
29
+ start_date_str = start_datetime.utc.strftime(date_format)
30
+ end_date_str = if end_datetime.blank?
31
+ "*"
32
+ else
33
+ end_datetime.utc.strftime(date_format)
34
+ end
35
+ "system_create_dtsi:[#{start_date_str} TO #{end_date_str}]"
36
+ end
37
+
38
+ delegate :count, to: :relation
39
+
40
+ def relation
41
+ Hyrax::WorkRelation.new
42
+ end
43
+
44
+ private
45
+
46
+ def where_access_is(access_level)
47
+ relation.where Hydra.config.permissions.read.group => access_level
48
+ end
49
+
50
+ def date_format
51
+ "%Y-%m-%dT%H:%M:%SZ"
52
+ end
53
+ end
54
+ end
55
+ end