sufia 6.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -5
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +2 -1
- data/History.md +69 -0
- data/README.md +84 -4
- data/SUFIA_VERSION +1 -1
- data/app/assets/images/zotero.png +0 -0
- data/app/assets/javascripts/sufia/featured_works.js +20 -3
- data/app/assets/stylesheets/generic_files.css.erb +2 -2
- data/app/assets/stylesheets/sufia.css.scss +2 -2
- data/app/assets/stylesheets/sufia/_buttons.scss +2 -2
- data/app/assets/stylesheets/sufia/_collections.scss +4 -4
- data/app/assets/stylesheets/sufia/_dashboard.scss +1 -1
- data/app/assets/stylesheets/sufia/_file-listing.scss +3 -0
- data/app/assets/stylesheets/sufia/_modal.scss +4 -0
- data/app/assets/stylesheets/sufia/_settings.scss +4 -3
- data/app/assets/stylesheets/sufia/_styles.scss +4 -0
- data/app/controllers/admin/stats_controller.rb +68 -0
- data/app/controllers/api/items_controller.rb +78 -0
- data/app/controllers/api/zotero_controller.rb +70 -0
- data/app/controllers/authorities_controller.rb +6 -5
- data/app/controllers/concerns/sufia/batch_edits_controller_behavior.rb +2 -1
- data/app/controllers/concerns/sufia/breadcrumbs.rb +1 -1
- data/app/controllers/concerns/sufia/depositors_controller_behavior.rb +11 -0
- data/app/controllers/concerns/sufia/files_controller/browse_everything.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller/local_ingest_behavior.rb +1 -1
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +23 -11
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +1 -7
- data/app/controllers/concerns/sufia/users_controller_behavior.rb +1 -2
- data/app/controllers/my/collections_controller.rb +1 -0
- data/app/controllers/my/files_controller.rb +1 -1
- data/app/helpers/sufia/sufia_helper_behavior.rb +28 -16
- data/app/models/my_search_builder.rb +4 -0
- data/app/search_builders/sufia/my_search_builder_behavior.rb +20 -0
- data/app/search_builders/sufia/search_builder.rb +1 -1
- data/app/views/admin/stats/index.html.erb +68 -0
- data/app/views/collections/_action_menu.html.erb +22 -20
- data/app/views/collections/_collection.html.erb +1 -1
- data/app/views/collections/_form_for_select_collection.html.erb +5 -3
- data/app/views/generic_files/_show_actions.html.erb +4 -2
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/layouts/sufia-dashboard.html.erb +5 -4
- data/app/views/layouts/sufia-one-column.html.erb +2 -0
- data/app/views/layouts/sufia-two-column.html.erb +6 -4
- data/app/views/my/_facet_layout.html.erb +2 -2
- data/app/views/my/_facets.html.erb +4 -6
- data/app/views/my/index.html.erb +4 -3
- data/app/views/users/_edit_primary.html.erb +18 -17
- data/app/views/users/_follower_modal.html.erb +5 -1
- data/app/views/users/_following_modal.html.erb +5 -1
- data/app/views/users/_user_info.html.erb +6 -1
- data/app/views/users/_zotero.html.erb +12 -0
- data/config/locales/sufia.en.yml +10 -1
- data/config/routes.rb +23 -1
- data/lib/generators/sufia/admin_stat_generator.rb +17 -0
- data/lib/generators/sufia/install_generator.rb +8 -3
- data/{sufia-models/lib/generators/sufia/models/templates/config/resque_admin.rb → lib/generators/sufia/templates/sufia/stats_admin.rb} +3 -3
- data/lib/generators/sufia/upgrade400_generator.rb +2 -2
- data/lib/sufia.rb +3 -0
- data/lib/sufia/arkivo.rb +11 -0
- data/lib/sufia/arkivo/actor.rb +95 -0
- data/lib/sufia/arkivo/config.rb +11 -0
- data/lib/sufia/arkivo/create_subscription_job.rb +67 -0
- data/lib/sufia/arkivo/metadata_munger.rb +51 -0
- data/lib/sufia/arkivo/schema_validator.rb +55 -0
- data/lib/sufia/form_builder.rb +1 -1
- data/lib/sufia/inflections.rb +3 -0
- data/lib/sufia/version.rb +1 -1
- data/lib/sufia/zotero.rb +6 -0
- data/lib/sufia/zotero/config.rb +15 -0
- data/solr_conf/conf/solrconfig.xml +11 -0
- data/spec/controllers/admin_stats_controller_spec.rb +73 -0
- data/spec/controllers/api/items_controller_spec.rb +476 -0
- data/spec/controllers/api/zotero_controller_spec.rb +178 -0
- data/spec/controllers/batch_edits_controller_spec.rb +7 -0
- data/spec/controllers/collections_controller_spec.rb +1 -1
- data/spec/controllers/dashboard_controller_spec.rb +1 -1
- data/spec/controllers/depositors_controller_spec.rb +9 -5
- data/spec/controllers/generic_files_controller_spec.rb +5 -4
- data/spec/controllers/mailbox_controller_spec.rb +2 -2
- data/spec/controllers/my/collections_controller_spec.rb +1 -2
- data/spec/controllers/my/files_controller_spec.rb +5 -5
- data/spec/controllers/my/shares_controller_spec.rb +15 -3
- data/spec/controllers/pages_controller_spec.rb +1 -1
- data/spec/controllers/users_controller_spec.rb +10 -9
- data/spec/factories/api_items.rb +91 -0
- data/spec/factories/generic_files.rb +4 -0
- data/spec/factories/users.rb +4 -4
- data/spec/features/featured_item_spec.rb +26 -0
- data/spec/features/ingest_upload_files_spec.rb +2 -3
- data/spec/features/proxy_spec.rb +0 -1
- data/spec/helpers/permissions_helper_spec.rb +2 -2
- data/spec/helpers/sufia_helper_spec.rb +11 -5
- data/spec/inputs/select_with_help_input_spec.rb +2 -2
- data/spec/javascripts/helpers/.gitkeep +0 -0
- data/spec/javascripts/helpers/jasmine-jquery.js +832 -0
- data/spec/javascripts/jasmine_spec.rb +31 -0
- data/spec/javascripts/notify_update_link_spec.js +8 -0
- data/spec/javascripts/single_use_link_spec.js.coffee +23 -0
- data/spec/javascripts/support/jasmine.yml +124 -0
- data/spec/javascripts/support/jasmine_helper.rb +15 -0
- data/spec/javascripts/terms_of_service_spec.js.coffee +32 -0
- data/spec/javascripts/toggle_icon_spec.js +11 -0
- data/spec/jobs/active_fedora_id_based_job_spec.rb +3 -3
- data/spec/jobs/import_url_job_spec.rb +0 -2
- data/spec/lib/sufia/arkivo/actor_spec.rb +139 -0
- data/spec/lib/sufia/arkivo/create_subscription_job_spec.rb +54 -0
- data/spec/lib/sufia/arkivo/metadata_munger_spec.rb +48 -0
- data/spec/lib/sufia/arkivo/schema_validator_spec.rb +65 -0
- data/spec/lib/sufia/upload_complete_behavior_spec.rb +1 -1
- data/spec/lib/sufia/user_stat_importer_spec.rb +60 -0
- data/spec/lib/sufia/zotero/config_spec.rb +30 -0
- data/spec/models/collection_spec.rb +36 -7
- data/spec/models/file_download_stat_spec.rb +5 -5
- data/spec/models/file_usage_spec.rb +23 -0
- data/spec/models/file_view_stat_spec.rb +6 -6
- data/spec/models/fits_datastream_spec.rb +0 -5
- data/spec/models/generic_file_spec.rb +49 -14
- data/spec/models/local_authority_spec.rb +1 -1
- data/spec/models/proxy_deposit_request_spec.rb +1 -1
- data/spec/models/trophy_spec.rb +8 -8
- data/spec/models/user_spec.rb +33 -0
- data/spec/presenters/sufia/collection_presenter_spec.rb +1 -1
- data/spec/routing/api_route_spec.rb +91 -0
- data/spec/routing/route_spec.rb +1 -1
- data/spec/services/generic_file_audit_service_spec.rb +44 -8
- data/spec/spec_helper.rb +18 -3
- data/spec/support/features.rb +0 -2
- data/spec/support/locations.rb +0 -21
- data/spec/support/rake.rb +41 -0
- data/spec/support/selectors.rb +0 -50
- data/spec/tasks/rake_spec.rb +33 -12
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +12 -0
- data/spec/views/admin/stats/index.html.erb_spec.rb +45 -0
- data/spec/views/catalog/sort_and_per_page.html.erb_spec.rb +0 -1
- data/spec/views/dashboard/index_spec.rb +1 -1
- data/spec/views/generic_file/edit.html.erb_spec.rb +1 -1
- data/spec/views/generic_file/show.html.erb_spec.rb +1 -3
- data/spec/views/users/_follower_modal.html.erb_spec.rb +44 -7
- data/spec/views/users/_following_modal.html.erb_spec.rb +49 -7
- data/spec/views/users/edit.html.erb_spec.rb +72 -0
- data/spec/views/users/show.html.erb_spec.rb +1 -1
- data/sufia.gemspec +6 -2
- data/tasks/sufia-user.rake +14 -0
- metadata +130 -156
- data/spec/lib/sufia/id_service_spec.rb +0 -32
- data/spec/services/noid_spec.rb +0 -9
- data/spec/support/poltergeist.rb +0 -11
- data/spec/support/rake_output.rb +0 -20
- data/sufia-models/.gitignore +0 -17
- data/sufia-models/Gemfile +0 -4
- data/sufia-models/LICENSE.md +0 -177
- data/sufia-models/README.md +0 -39
- data/sufia-models/Rakefile +0 -1
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +0 -137
- data/sufia-models/app/jobs/active_fedora_id_based_job.rb +0 -22
- data/sufia-models/app/jobs/active_fedora_pid_based_job.rb +0 -7
- data/sufia-models/app/jobs/audit_job.rb +0 -62
- data/sufia-models/app/jobs/batch_update_job.rb +0 -72
- data/sufia-models/app/jobs/characterize_job.rb +0 -10
- data/sufia-models/app/jobs/create_derivatives_job.rb +0 -14
- data/sufia-models/app/jobs/import_url_job.rb +0 -52
- data/sufia-models/app/jobs/ingest_local_file_job.rb +0 -46
- data/sufia-models/app/jobs/resolrize_job.rb +0 -9
- data/sufia-models/app/models/batch.rb +0 -36
- data/sufia-models/app/models/checksum_audit_log.rb +0 -21
- data/sufia-models/app/models/concerns/sufia/ability.rb +0 -61
- data/sufia-models/app/models/concerns/sufia/collection_behavior.rb +0 -24
- data/sufia-models/app/models/concerns/sufia/file_stat_utils.rb +0 -35
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -25
- data/sufia-models/app/models/concerns/sufia/generic_file/batches.rb +0 -28
- data/sufia-models/app/models/concerns/sufia/generic_file/characterization.rb +0 -89
- data/sufia-models/app/models/concerns/sufia/generic_file/content.rb +0 -13
- data/sufia-models/app/models/concerns/sufia/generic_file/derivatives.rb +0 -26
- data/sufia-models/app/models/concerns/sufia/generic_file/export.rb +0 -343
- data/sufia-models/app/models/concerns/sufia/generic_file/featured.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/full_text_indexing.rb +0 -43
- data/sufia-models/app/models/concerns/sufia/generic_file/indexing.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +0 -98
- data/sufia-models/app/models/concerns/sufia/generic_file/mime_types.rb +0 -69
- data/sufia-models/app/models/concerns/sufia/generic_file/permissions.rb +0 -11
- data/sufia-models/app/models/concerns/sufia/generic_file/proxy_deposit.rb +0 -31
- data/sufia-models/app/models/concerns/sufia/generic_file/trophies.rb +0 -14
- data/sufia-models/app/models/concerns/sufia/generic_file/versions.rb +0 -16
- data/sufia-models/app/models/concerns/sufia/generic_file/virus_check.rb +0 -37
- data/sufia-models/app/models/concerns/sufia/model_methods.rb +0 -20
- data/sufia-models/app/models/concerns/sufia/user.rb +0 -137
- data/sufia-models/app/models/concerns/sufia/user_usage_stats.rb +0 -15
- data/sufia-models/app/models/datastreams/file_content_datastream.rb +0 -4
- data/sufia-models/app/models/datastreams/fits_datastream.rb +0 -152
- data/sufia-models/app/models/domain_term.rb +0 -5
- data/sufia-models/app/models/featured_work.rb +0 -22
- data/sufia-models/app/models/file_download_stat.rb +0 -18
- data/sufia-models/app/models/file_usage.rb +0 -34
- data/sufia-models/app/models/file_view_stat.rb +0 -18
- data/sufia-models/app/models/follow.rb +0 -12
- data/sufia-models/app/models/generic_file.rb +0 -3
- data/sufia-models/app/models/geo_names_resource.rb +0 -18
- data/sufia-models/app/models/group.rb +0 -8
- data/sufia-models/app/models/local_authority.rb +0 -86
- data/sufia-models/app/models/local_authority_entry.rb +0 -3
- data/sufia-models/app/models/proxy_deposit_request.rb +0 -85
- data/sufia-models/app/models/proxy_deposit_rights.rb +0 -4
- data/sufia-models/app/models/single_use_link.rb +0 -42
- data/sufia-models/app/models/subject_local_authority_entry.rb +0 -2
- data/sufia-models/app/models/sufia/avatar_uploader.rb +0 -20
- data/sufia-models/app/models/sufia/avatar_validator.rb +0 -8
- data/sufia-models/app/models/sufia/collection.rb +0 -5
- data/sufia-models/app/models/sufia/download.rb +0 -9
- data/sufia-models/app/models/sufia/orcid_validator.rb +0 -12
- data/sufia-models/app/models/sufia/pageview.rb +0 -9
- data/sufia-models/app/models/trophy.rb +0 -10
- data/sufia-models/app/models/user_stat.rb +0 -2
- data/sufia-models/app/models/version_committer.rb +0 -2
- data/sufia-models/app/services/sufia/analytics.rb +0 -50
- data/sufia-models/app/services/sufia/generic_file_audit_service.rb +0 -83
- data/sufia-models/app/services/sufia/generic_file_indexing_service.rb +0 -12
- data/sufia-models/app/services/sufia/id_service.rb +0 -45
- data/sufia-models/app/services/sufia/noid.rb +0 -22
- data/sufia-models/app/services/sufia/repository_audit_service.rb +0 -9
- data/sufia-models/config/locales/sufia.en.yml +0 -6
- data/sufia-models/lib/generators/sufia/models/abstract_migration_generator.rb +0 -30
- data/sufia-models/lib/generators/sufia/models/cached_stats_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/fulltext_generator.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +0 -106
- data/sufia-models/lib/generators/sufia/models/orcid_field_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/proxies_generator.rb +0 -24
- data/sufia-models/lib/generators/sufia/models/templates/app/models/collection.rb +0 -2
- data/sufia-models/lib/generators/sufia/models/templates/config/analytics.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/clamav.rb +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/mailboxer.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/config/mime_types.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/config/redis.yml +0 -9
- data/sufia-models/lib/generators/sufia/models/templates/config/redis_config.rb +0 -32
- data/sufia-models/lib/generators/sufia/models/templates/config/resque-pool.yml +0 -1
- data/sufia-models/lib/generators/sufia/models/templates/config/resque_config.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +0 -3
- data/sufia-models/lib/generators/sufia/models/templates/config/solrconfig.xml +0 -223
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +0 -144
- data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +0 -17
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_external_key_to_content_blocks.rb +0 -6
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb +0 -27
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_linkedin_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_orcid_to_users.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/add_social_to_users.rb +0 -13
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_audit_log_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/change_proxy_deposit_request_pid_to_generic_file_id.rb +0 -5
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_content_blocks.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_featured_works.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_download_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_file_view_stats.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +0 -50
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_requests.rb +0 -16
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_proxy_deposit_rights.rb +0 -11
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_single_use_links.rb +0 -12
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_tinymce_assets.rb +0 -8
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_trophies.rb +0 -10
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_user_stats.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/templates/migrations/create_version_committers.rb +0 -15
- data/sufia-models/lib/generators/sufia/models/update_content_blocks_generator.rb +0 -18
- data/sufia-models/lib/generators/sufia/models/upgrade400_generator.rb +0 -54
- data/sufia-models/lib/generators/sufia/models/upgrade600_generator.rb +0 -21
- data/sufia-models/lib/generators/sufia/models/usagestats_generator.rb +0 -19
- data/sufia-models/lib/generators/sufia/models/user_stats_generator.rb +0 -31
- data/sufia-models/lib/sufia/messages.rb +0 -66
- data/sufia-models/lib/sufia/models.rb +0 -34
- data/sufia-models/lib/sufia/models/active_fedora/redis.rb +0 -43
- data/sufia-models/lib/sufia/models/active_record/redis.rb +0 -56
- data/sufia-models/lib/sufia/models/engine.rb +0 -79
- data/sufia-models/lib/sufia/models/file_content.rb +0 -6
- data/sufia-models/lib/sufia/models/file_content/versions.rb +0 -21
- data/sufia-models/lib/sufia/models/resque.rb +0 -36
- data/sufia-models/lib/sufia/models/stats/user_stat_importer.rb +0 -108
- data/sufia-models/lib/sufia/models/user_local_directory_behavior.rb +0 -29
- data/sufia-models/lib/sufia/models/utils.rb +0 -22
- data/sufia-models/lib/sufia/models/version.rb +0 -5
- data/sufia-models/lib/sufia/models/virus_found_error.rb +0 -4
- data/sufia-models/lib/sufia/permissions.rb +0 -9
- data/sufia-models/lib/sufia/permissions/readable.rb +0 -20
- data/sufia-models/lib/sufia/permissions/writable.rb +0 -74
- data/sufia-models/lib/tasks/batch_cleanup.rake +0 -19
- data/sufia-models/lib/tasks/migrate.rake +0 -21
- data/sufia-models/lib/tasks/resque.rake +0 -13
- data/sufia-models/lib/tasks/stats_tasks.rake +0 -12
- data/sufia-models/lib/tasks/sufia-models_tasks.rake +0 -80
- data/sufia-models/sufia-models.gemspec +0 -52
@@ -1,21 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
module FileContent
|
3
|
-
module Versions
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
has_many_versions
|
8
|
-
end
|
9
|
-
|
10
|
-
def latest_version
|
11
|
-
versions.last unless versions.empty?
|
12
|
-
end
|
13
|
-
|
14
|
-
def save
|
15
|
-
super.tap do |passing|
|
16
|
-
create_version if passing
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# Borrowed from:
|
2
|
-
# https://github.com/jeremy/resque-rails/blob/master/lib/resque/rails/queue.rb
|
3
|
-
module Sufia
|
4
|
-
module Resque
|
5
|
-
class Queue
|
6
|
-
attr_reader :default_queue_name
|
7
|
-
|
8
|
-
def initialize(default_queue_name)
|
9
|
-
@default_queue_name = default_queue_name
|
10
|
-
end
|
11
|
-
|
12
|
-
def push(job)
|
13
|
-
push_tries = 0
|
14
|
-
queue = job.respond_to?(:queue_name) ? job.queue_name : default_queue_name
|
15
|
-
begin
|
16
|
-
::Resque.enqueue_to queue, MarshaledJob, Base64.encode64(Marshal.dump(job))
|
17
|
-
rescue Redis::CannotConnectError
|
18
|
-
ActiveFedora::Base.logger.error "Redis is down!"
|
19
|
-
rescue Redis::TimeoutError => error
|
20
|
-
ActiveFedora::Base.logger.warn "Redis Timed out. Trying again! #{job.inspect}"
|
21
|
-
push_tries+=1
|
22
|
-
# fail for good if the tries is greater than 3
|
23
|
-
raise error if push_tries >=3
|
24
|
-
sleep 0.01
|
25
|
-
retry
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class MarshaledJob
|
31
|
-
def self.perform(marshaled_job)
|
32
|
-
Marshal.load(Base64.decode64(marshaled_job)).run
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
class UserStatImporter
|
3
|
-
|
4
|
-
UserRecord = Struct.new("UserRecord", :id, :user_key, :last_stats_update)
|
5
|
-
|
6
|
-
def initialize(options={})
|
7
|
-
@verbose = options[:verbose]
|
8
|
-
@logging = options[:logging]
|
9
|
-
@delay_secs = options[:delay_secs].to_f
|
10
|
-
end
|
11
|
-
|
12
|
-
def import
|
13
|
-
log_message('Begin import of User stats.')
|
14
|
-
sorted_users.each do |user|
|
15
|
-
start_date = date_since_last_cache(user)
|
16
|
-
|
17
|
-
stats = {}
|
18
|
-
file_ids_for_user(user).each do |file_id|
|
19
|
-
view_stats = FileViewStat.statistics(file_id, start_date, user.id)
|
20
|
-
stats = tally_results(view_stats, :views, stats)
|
21
|
-
delay
|
22
|
-
|
23
|
-
dl_stats = FileDownloadStat.statistics(file_id, start_date, user.id)
|
24
|
-
stats = tally_results(dl_stats, :downloads, stats)
|
25
|
-
delay
|
26
|
-
end
|
27
|
-
|
28
|
-
create_or_update_user_stats(stats, user)
|
29
|
-
end
|
30
|
-
log_message('User stats import complete.')
|
31
|
-
end
|
32
|
-
|
33
|
-
# Returns an array of users sorted by the date of their last
|
34
|
-
# stats update. Users that have not been recently updated
|
35
|
-
# will be at the top of the array.
|
36
|
-
def sorted_users
|
37
|
-
users = []
|
38
|
-
::User.find_each do |user|
|
39
|
-
users.push(UserRecord.new(user.id, user.user_key, date_since_last_cache(user)))
|
40
|
-
end
|
41
|
-
users.sort! {|a, b| a.last_stats_update <=> b.last_stats_update}
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def delay
|
47
|
-
sleep @delay_secs
|
48
|
-
end
|
49
|
-
|
50
|
-
def date_since_last_cache(user)
|
51
|
-
last_cached_stat = UserStat.where(user_id: user.id).order(date: :asc).last
|
52
|
-
|
53
|
-
if last_cached_stat
|
54
|
-
last_cached_stat.date + 1.day
|
55
|
-
else
|
56
|
-
Sufia.config.analytic_start_date
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def file_ids_for_user(user)
|
61
|
-
ids = []
|
62
|
-
::GenericFile.find_in_batches("#{Solrizer.solr_name('depositor', :symbol)}:\"#{user.user_key}\"", fl:"id") do |group|
|
63
|
-
ids.concat group.map { |doc| doc["id"] }
|
64
|
-
end
|
65
|
-
ids
|
66
|
-
end
|
67
|
-
|
68
|
-
# For each date, add the view and download counts for this
|
69
|
-
# file to the view & download sub-totals for that day.
|
70
|
-
# The resulting hash will look something like this:
|
71
|
-
# {"2014-11-30 00:00:00 UTC" => {:views=>2, :downloads=>5},
|
72
|
-
# "2014-12-01 00:00:00 UTC" => {:views=>4, :downloads=>4}}
|
73
|
-
def tally_results(file_stats, stat_name, total_stats)
|
74
|
-
file_stats.each do |stats|
|
75
|
-
# Exclude the stats from today since it will only be a partial day's worth of data
|
76
|
-
break if stats.date == Date.today
|
77
|
-
|
78
|
-
date_key = stats.date.to_s
|
79
|
-
old_count = total_stats[date_key] ? total_stats[date_key].fetch(stat_name) { 0 } : 0
|
80
|
-
new_count = old_count + stats.method(stat_name).call
|
81
|
-
|
82
|
-
old_values = total_stats[date_key] || {}
|
83
|
-
total_stats.store(date_key, old_values)
|
84
|
-
total_stats[date_key].store(stat_name, new_count)
|
85
|
-
end
|
86
|
-
total_stats
|
87
|
-
end
|
88
|
-
|
89
|
-
def create_or_update_user_stats(stats, user)
|
90
|
-
stats.each do |date_string, data|
|
91
|
-
date = Time.zone.parse(date_string)
|
92
|
-
|
93
|
-
user_stat = UserStat.where(user_id: user.id).where(date: date).first
|
94
|
-
user_stat ||= UserStat.new(user_id: user.id, date: date)
|
95
|
-
|
96
|
-
user_stat.file_views = data[:views] || 0
|
97
|
-
user_stat.file_downloads = data[:downloads] || 0
|
98
|
-
user_stat.save!
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
def log_message(message)
|
103
|
-
puts message if @verbose
|
104
|
-
Rails.logger.info "#{self.class}: #{message}" if @logging
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# To enable local file ingest,
|
2
|
-
# - Make User model define .directory method that returns a String corresponding to the User's personal import directory on the server. This can be a simple ActiveRecord attribute on the User model, or it can be something more elaborate.
|
3
|
-
# - Include this module in your User model, or define a .files() method that behaves the same
|
4
|
-
# - Set Sufia.config.enable_local_ingest to true
|
5
|
-
#
|
6
|
-
module Sufia::UserLocalDirectoryBehavior
|
7
|
-
|
8
|
-
# You can use this validator in your User model.
|
9
|
-
# Ensures that a string defining the path to the user's directory has been provided
|
10
|
-
# and corresponds to a real directory on the server.
|
11
|
-
# @example
|
12
|
-
# validate :directory_must_exist
|
13
|
-
def directory_must_exist
|
14
|
-
unless directory.blank? || File.directory?(directory)
|
15
|
-
errors.add(:directory, "must be an existing directory")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
# List the contents of the user's directory on the server
|
20
|
-
# Indicates whether each item is a directory or not.
|
21
|
-
def files
|
22
|
-
return [] unless directory.present? && File.directory?(directory)
|
23
|
-
Dir[File.join(directory, '*')].inject([]) do |accum, val|
|
24
|
-
accum << { name: File.basename(val), directory: File.directory?(val)}
|
25
|
-
accum
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
module Utils
|
3
|
-
extend ActiveSupport::Concern
|
4
|
-
|
5
|
-
def retry_unless(number_of_tries, condition, &block)
|
6
|
-
self.class.retry_unless(number_of_tries, condition, &block)
|
7
|
-
end
|
8
|
-
|
9
|
-
module ClassMethods
|
10
|
-
def retry_unless(number_of_tries, condition, &block)
|
11
|
-
raise ArgumentError, "First argument must be an enumerator" unless number_of_tries.is_a? Enumerator
|
12
|
-
raise ArgumentError, "Second argument must be a lambda" unless condition.respond_to? :call
|
13
|
-
raise ArgumentError, "Must pass a block of code to retry" unless block_given?
|
14
|
-
number_of_tries.each do
|
15
|
-
result = block.call
|
16
|
-
return result unless condition.call
|
17
|
-
end
|
18
|
-
raise RuntimeError, "retry_unless could not complete successfully. Try upping the # of tries?"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
module Permissions
|
3
|
-
module Readable
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
def public?
|
7
|
-
read_groups.include?('public')
|
8
|
-
end
|
9
|
-
|
10
|
-
def registered?
|
11
|
-
read_groups.include?('registered')
|
12
|
-
end
|
13
|
-
|
14
|
-
def private?
|
15
|
-
!(public? || registered?)
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module Sufia
|
2
|
-
module Permissions
|
3
|
-
module Writable
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
#we're overriding the permissions= method which is in Hydra::AccessControls::Permissions
|
7
|
-
include Hydra::AccessControls::Permissions
|
8
|
-
include Hydra::AccessControls::Visibility
|
9
|
-
|
10
|
-
included do
|
11
|
-
validate :paranoid_permissions
|
12
|
-
end
|
13
|
-
|
14
|
-
def paranoid_permissions
|
15
|
-
valid = true
|
16
|
-
VALIDATIONS.each do |validation|
|
17
|
-
if validation[:condition].call(self)
|
18
|
-
errors[validation[:key]] ||= []
|
19
|
-
errors[validation[:key]] << validation[:message]
|
20
|
-
valid = false
|
21
|
-
end
|
22
|
-
end
|
23
|
-
return valid
|
24
|
-
end
|
25
|
-
|
26
|
-
VALIDATIONS = [
|
27
|
-
{key: :edit_users, message: 'Depositor must have edit access', condition: lambda { |obj| !obj.edit_users.include?(obj.depositor) }},
|
28
|
-
{key: :edit_groups, message: 'Public cannot have edit access', condition: lambda { |obj| obj.edit_groups.include?('public') }},
|
29
|
-
{key: :edit_groups, message: 'Registered cannot have edit access', condition: lambda { |obj| obj.edit_groups.include?('registered') }}
|
30
|
-
]
|
31
|
-
|
32
|
-
|
33
|
-
def clear_permissions!
|
34
|
-
self.permissions = []
|
35
|
-
end
|
36
|
-
|
37
|
-
## Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
|
38
|
-
# def permissions=(params)
|
39
|
-
# raise "Fixme #{params}"
|
40
|
-
# perm_hash = permission_hash
|
41
|
-
# params[:new_user_name].each { |name, access| perm_hash['person'][name] = access } if params[:new_user_name].present?
|
42
|
-
# params[:new_group_name].each { |name, access| perm_hash['group'][name] = access } if params[:new_group_name].present?
|
43
|
-
|
44
|
-
# params[:user].each { |name, access| perm_hash['person'][name] = access} if params[:user]
|
45
|
-
# params[:group].each { |name, access| perm_hash['group'][name] = access if ['read', 'edit'].include?(access)} if params[:group]
|
46
|
-
|
47
|
-
# # rightsMetadata.update_permissions(perm_hash)
|
48
|
-
# end
|
49
|
-
|
50
|
-
# def permissions
|
51
|
-
# raise "Fixme "
|
52
|
-
# perms = super
|
53
|
-
# perms.map {|p| { name: p.name, access: p.access, type:p.type } }
|
54
|
-
# end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def permission_hash
|
59
|
-
old_perms = self.permissions
|
60
|
-
user_perms = {}
|
61
|
-
old_perms.select{|r| r[:type] == 'user'}.each do |r|
|
62
|
-
user_perms[r[:name]] = r[:access]
|
63
|
-
end
|
64
|
-
user_perms
|
65
|
-
group_perms = {}
|
66
|
-
old_perms.select{|r| r[:type] == 'group'}.each do |r|
|
67
|
-
group_perms[r[:name]] = r[:access]
|
68
|
-
end
|
69
|
-
{'person'=>user_perms, 'group'=>group_perms}
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
namespace :sufia do
|
2
|
-
|
3
|
-
desc "Reports on and optionally removes empty batches that contain no associated files"
|
4
|
-
task :empty_batches, [:remove] => :environment do |t, args|
|
5
|
-
option = args.to_hash.fetch(:remove, "keep")
|
6
|
-
Batch.all.each do |batch|
|
7
|
-
if batch.generic_files.empty?
|
8
|
-
print "#{batch.id} contains no files - "
|
9
|
-
if option == "remove"
|
10
|
-
batch.destroy
|
11
|
-
puts "deleted"
|
12
|
-
else
|
13
|
-
puts "to delete, rerun with the remove option: rake sufia:empty_batches[remove]"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
namespace :sufia do
|
2
|
-
namespace :migrate do
|
3
|
-
|
4
|
-
desc "Migrate proxy deposits"
|
5
|
-
task proxy_deposits: :environment do
|
6
|
-
ProxyDepositRequest.all.each do |pd|
|
7
|
-
pd.generic_file_id = pd.generic_file_id.delete "#{Sufia.config.redis_namespace}:"
|
8
|
-
pd.save
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
desc "Migrate audit logs"
|
13
|
-
task audit_logs: :environment do
|
14
|
-
ChecksumAuditLog.all.each do |cs|
|
15
|
-
cs.generic_file_id = cs.generic_file_id.delete "#{Sufia.config.redis_namespace}:"
|
16
|
-
cs.save
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'resque/pool/tasks'
|
2
|
-
|
3
|
-
# This provides access to the Rails env within all Resque workers
|
4
|
-
task 'resque:setup' => :environment
|
5
|
-
|
6
|
-
# Set up resque-pool
|
7
|
-
task 'resque:pool:setup' do
|
8
|
-
ActiveRecord::Base.connection.disconnect!
|
9
|
-
Resque::Pool.after_prefork do |job|
|
10
|
-
ActiveRecord::Base.establish_connection
|
11
|
-
Resque.redis.client.reconnect
|
12
|
-
end
|
13
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
namespace :sufia do
|
2
|
-
namespace :stats do
|
3
|
-
|
4
|
-
desc "Cache file view & download stats for all users"
|
5
|
-
task :user_stats => :environment do
|
6
|
-
require 'sufia/models/stats/user_stat_importer'
|
7
|
-
importer = Sufia::UserStatImporter.new(verbose: true, logging: true)
|
8
|
-
importer.import
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'net/http'
|
2
|
-
|
3
|
-
namespace :solr do
|
4
|
-
desc "Enqueue a job to resolrize the repository objects"
|
5
|
-
task reindex: :environment do
|
6
|
-
Sufia.queue.push(ResolrizeJob.new)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
namespace :sufia do
|
11
|
-
namespace :jetty do
|
12
|
-
|
13
|
-
FULLTEXT_JARS = %w(
|
14
|
-
org/apache/james/apache-mime4j-core/0.7.2/apache-mime4j-core-0.7.2.jar
|
15
|
-
org/apache/james/apache-mime4j-dom/0.7.2/apache-mime4j-dom-0.7.2.jar
|
16
|
-
org/apache/solr/solr-cell/4.0.0/solr-cell-4.0.0.jar
|
17
|
-
org/bouncycastle/bcmail-jdk15/1.45/bcmail-jdk15-1.45.jar
|
18
|
-
org/bouncycastle/bcprov-jdk15/1.45/bcprov-jdk15-1.45.jar
|
19
|
-
de/l3s/boilerpipe/boilerpipe/1.1.0/boilerpipe-1.1.0.jar
|
20
|
-
org/apache/commons/commons-compress/1.4.1/commons-compress-1.4.1.jar
|
21
|
-
dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
|
22
|
-
org/apache/pdfbox/fontbox/1.7.0/fontbox-1.7.0.jar
|
23
|
-
com/ibm/icu/icu4j/49.1/icu4j-49.1.jar
|
24
|
-
com/googlecode/mp4parser/isoparser/1.0-RC-1/isoparser-1.0-RC-1.jar
|
25
|
-
jdom/jdom/1.0/jdom-1.0.jar
|
26
|
-
org/apache/pdfbox/jempbox/1.7.0/jempbox-1.7.0.jar
|
27
|
-
com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.jar
|
28
|
-
com/drewnoakes/metadata-extractor/2.4.0-beta-1/metadata-extractor-2.4.0-beta-1.jar
|
29
|
-
edu/ucar/netcdf/4.2-min/netcdf-4.2-min.jar
|
30
|
-
org/apache/pdfbox/pdfbox/1.7.0/pdfbox-1.7.0.jar
|
31
|
-
org/apache/poi/poi/3.8/poi-3.8.jar
|
32
|
-
org/apache/poi/poi-ooxml/3.8/poi-ooxml-3.8.jar
|
33
|
-
org/apache/poi/poi-ooxml-schemas/3.8/poi-ooxml-schemas-3.8.jar
|
34
|
-
org/apache/poi/poi-scratchpad/3.8/poi-scratchpad-3.8.jar
|
35
|
-
rome/rome/0.9/rome-0.9.jar
|
36
|
-
org/ccil/cowan/tagsoup/tagsoup/1.2.1/tagsoup-1.2.1.jar
|
37
|
-
org/apache/tika/tika-core/1.2/tika-core-1.2.jar
|
38
|
-
org/apache/tika/tika-parsers/1.2/tika-parsers-1.2.jar
|
39
|
-
org/gagravarr/vorbis-java-core/0.1/vorbis-java-core-0.1.jar
|
40
|
-
org/gagravarr/vorbis-java-tika/0.1/vorbis-java-tika-0.1.jar
|
41
|
-
xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar
|
42
|
-
org/apache/xmlbeans/xmlbeans/2.3.0/xmlbeans-2.3.0.jar
|
43
|
-
org/tukaani/xz/1.0/xz-1.0.jar
|
44
|
-
org/aspectj/aspectjrt/1.8.5/aspectjrt-1.8.5.jar
|
45
|
-
)
|
46
|
-
|
47
|
-
desc 'Configure jetty with full-text indexing'
|
48
|
-
task config: :download_jars do
|
49
|
-
Rake::Task['jetty:config'].invoke
|
50
|
-
end
|
51
|
-
|
52
|
-
desc 'Download Solr full-text extraction jars'
|
53
|
-
task :download_jars do
|
54
|
-
puts "Downloading full-text jars from maven.org ..."
|
55
|
-
fulltext_dir = 'jetty/solr/lib/contrib/extraction/lib'
|
56
|
-
FileUtils.mkdir_p(fulltext_dir) unless File.directory?(fulltext_dir)
|
57
|
-
Dir.chdir(fulltext_dir) do
|
58
|
-
FULLTEXT_JARS.each do |jar|
|
59
|
-
destination = jar.split('/').last
|
60
|
-
download_from_maven(jar, destination) unless File.exists?(destination)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def download_from_maven url, dst
|
68
|
-
full_url = '/remotecontent?filepath=' + url
|
69
|
-
file = File.open(dst, "w")
|
70
|
-
Net::HTTP.start("search.maven.org") do |http|
|
71
|
-
puts "Fetching #{full_url}"
|
72
|
-
begin
|
73
|
-
http.request_get(full_url) do |resp|
|
74
|
-
resp.read_body { |segment| file.write(segment) }
|
75
|
-
end
|
76
|
-
ensure
|
77
|
-
file.close
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|