sufia-models 4.0.0 → 4.0.1
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 +4 -4
- data/app/actors/sufia/generic_file/actor.rb +8 -1
- data/app/jobs/import_url_job.rb +1 -1
- data/app/models/concerns/sufia/generic_file/audit.rb +16 -12
- data/app/models/file_usage.rb +4 -2
- data/lib/generators/sufia/models/install_generator.rb +1 -0
- data/lib/generators/sufia/models/templates/config/resque-pool.yml +1 -0
- data/lib/generators/sufia/models/templates/config/sufia.rb +8 -0
- data/lib/sufia/models/engine.rb +4 -0
- data/lib/sufia/models/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 225e822263154c92055f19c4a792469b2ce46065
|
4
|
+
data.tar.gz: 710dd7bb7969847ac3362645003d0fc8b0533fde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43c341a486f46e61218acb3db3b75cf15fc6e981da57517357fb2c483faf8c22358940510e0edb4f52427e58167f4f4a4902dd317630873179bc96ca70c2a909
|
7
|
+
data.tar.gz: a5469d79e6280e930455bfa6b7241e3c467dfc970a704aae4129bab69c0563783ca913ed2022cb5a7ae8e8260ca5e6d9513a7095e9129ae9503574099d035ff6
|
@@ -58,7 +58,7 @@ module Sufia::GenericFile
|
|
58
58
|
|
59
59
|
def update_metadata(attributes, visibility)
|
60
60
|
generic_file.attributes = generic_file.sanitize_attributes(attributes)
|
61
|
-
|
61
|
+
update_visibility(visibility)
|
62
62
|
generic_file.date_modified = DateTime.now
|
63
63
|
remove_from_feature_works if generic_file.visibility_changed? && !generic_file.public?
|
64
64
|
save_and_record_committer do
|
@@ -118,6 +118,13 @@ module Sufia::GenericFile
|
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
+
protected
|
122
|
+
|
123
|
+
# This method can be overridden in case there is a custom approach for visibility (e.g. embargo)
|
124
|
+
def update_visibility(visibility)
|
125
|
+
generic_file.visibility = visibility
|
126
|
+
end
|
127
|
+
|
121
128
|
private
|
122
129
|
def remove_from_feature_works
|
123
130
|
featured_work = FeaturedWork.find_by_generic_file_id(generic_file.noid)
|
data/app/jobs/import_url_job.rb
CHANGED
@@ -16,7 +16,7 @@ class ImportUrlJob < ActiveFedoraPidBasedJob
|
|
16
16
|
# attach downloaded file to generic file stubbed out
|
17
17
|
if Sufia::GenericFile::Actor.new(generic_file, user).create_content(f, path, 'content')
|
18
18
|
# add message to user for downloaded file
|
19
|
-
message = "The file (#{
|
19
|
+
message = "The file (#{generic_file.content.label}) was successfully imported."
|
20
20
|
job_user.send_message(user, message, 'File Import')
|
21
21
|
else
|
22
22
|
job_user.send_message(user, generic_file.errors.full_messages.join(', '), 'File Import Error')
|
@@ -8,7 +8,7 @@ module Sufia
|
|
8
8
|
def audit(force = false)
|
9
9
|
logs = []
|
10
10
|
self.per_version do |ver|
|
11
|
-
logs <<
|
11
|
+
logs << audit_each(ver, force)
|
12
12
|
end
|
13
13
|
logs
|
14
14
|
end
|
@@ -51,23 +51,27 @@ module Sufia
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
def audit_each(version, force = false)
|
55
|
+
latest_audit = logs(version.dsid).first
|
56
|
+
return latest_audit unless force || ::GenericFile.needs_audit?(version, latest_audit)
|
57
|
+
|
58
|
+
# Resque.enqueue(AuditJob, version.pid, version.dsid, version.versionID)
|
59
|
+
Sufia.queue.push(AuditJob.new(version.pid, version.dsid, version.versionID))
|
60
|
+
|
61
|
+
# run the find just incase the job has finished already
|
62
|
+
latest_audit = logs(version.dsid).first
|
63
|
+
latest_audit = ChecksumAuditLog.new(pass: NO_RUNS, pid: version.pid, dsid: version.dsid, version: version.versionID) unless latest_audit
|
64
|
+
latest_audit
|
65
|
+
end
|
66
|
+
|
67
|
+
|
54
68
|
module ClassMethods
|
55
69
|
def audit!(version)
|
56
70
|
::GenericFile.audit(version, true)
|
57
71
|
end
|
58
72
|
|
59
73
|
def audit(version, force = false)
|
60
|
-
latest_audit = self.find(version.pid).
|
61
|
-
unless force
|
62
|
-
return latest_audit unless ::GenericFile.needs_audit?(version, latest_audit)
|
63
|
-
end
|
64
|
-
# Resque.enqueue(AuditJob, version.pid, version.dsid, version.versionID)
|
65
|
-
Sufia.queue.push(AuditJob.new(version.pid, version.dsid, version.versionID))
|
66
|
-
|
67
|
-
# run the find just incase the job has finished already
|
68
|
-
latest_audit = self.find(version.pid).logs(version.dsid).first
|
69
|
-
latest_audit = ChecksumAuditLog.new(pass: NO_RUNS, pid: version.pid, dsid: version.dsid, version: version.versionID) unless latest_audit
|
70
|
-
latest_audit
|
74
|
+
latest_audit = self.find(version.pid).audit_each( version, force)
|
71
75
|
end
|
72
76
|
|
73
77
|
def needs_audit?(version, latest_audit)
|
data/app/models/file_usage.rb
CHANGED
@@ -5,7 +5,9 @@ class FileUsage
|
|
5
5
|
def initialize id
|
6
6
|
self.id = id
|
7
7
|
self.path = Sufia::Engine.routes.url_helpers.generic_file_path(Sufia::Noid.noidify(id))
|
8
|
+
earliest = Sufia.config.analytic_start_date
|
8
9
|
self.created = DateTime.parse(::GenericFile.find(id).create_date)
|
10
|
+
self.created = earliest > created ? earliest : created unless earliest.blank?
|
9
11
|
self.downloads = download_statistics
|
10
12
|
self.pageviews = pageview_statistics
|
11
13
|
end
|
@@ -31,13 +33,13 @@ class FileUsage
|
|
31
33
|
# Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
|
32
34
|
# see Legato::ProfileMethods.method_name_from_klass
|
33
35
|
def download_statistics
|
34
|
-
Sufia::Analytics.profile.sufia__download(sort: 'date').for_file(self.id)
|
36
|
+
Sufia::Analytics.profile.sufia__download(sort: 'date', start_date: created).for_file(self.id)
|
35
37
|
end
|
36
38
|
|
37
39
|
# Sufia::Pageview is sent to Sufia::Analytics.profile as #sufia__pageview
|
38
40
|
# see Legato::ProfileMethods.method_name_from_klass
|
39
41
|
def pageview_statistics
|
40
|
-
Sufia::Analytics.profile.sufia__pageview(sort: 'date').for_path(self.path)
|
42
|
+
Sufia::Analytics.profile.sufia__pageview(sort: 'date', start_date: created).for_path(self.path)
|
41
43
|
end
|
42
44
|
|
43
45
|
def pageviews_to_flot values = Array.new
|
@@ -79,6 +79,7 @@ This generator makes the following changes to your application:
|
|
79
79
|
"\nMime::Type.register 'application/x-endnote-refer', :endnote", {verbose: false }
|
80
80
|
copy_file 'config/sufia.rb', 'config/initializers/sufia.rb'
|
81
81
|
copy_file 'config/redis.yml', 'config/redis.yml'
|
82
|
+
copy_file 'config/resque-pool.yml', 'config/resque-pool.yml'
|
82
83
|
copy_file 'config/redis_config.rb', 'config/initializers/redis_config.rb'
|
83
84
|
copy_file 'config/resque_admin.rb', 'config/initializers/resque_admin.rb'
|
84
85
|
copy_file 'config/resque_config.rb', 'config/initializers/resque_config.rb'
|
@@ -0,0 +1 @@
|
|
1
|
+
"*": 1
|
@@ -105,6 +105,14 @@ Sufia.config do |config|
|
|
105
105
|
# Specify the path to the file characterization tool:
|
106
106
|
# config.fits_path = "fits.sh"
|
107
107
|
|
108
|
+
# Specify how many seconds back from the current time that we should show by default of the user's activity on the user's dashboard
|
109
|
+
# config.activity_to_show_default_seconds_since_now = 24*60*60
|
110
|
+
|
111
|
+
# Specify a date you wish to start collecting Google Analytic statistics for.
|
112
|
+
# Leaving it blank will set the start date to when ever the file was uploaded by
|
113
|
+
# NOTE: if you have always sent analytics to GA for downloads and page views leave this commented out
|
114
|
+
# config.analytic_start_date = DateTime.new(2014,9,10)
|
115
|
+
|
108
116
|
# If browse-everything has been configured, load the configs. Otherwise, set to nil.
|
109
117
|
begin
|
110
118
|
if defined? BrowseEverything
|
data/lib/sufia/models/engine.rb
CHANGED
@@ -26,6 +26,10 @@ module Sufia
|
|
26
26
|
config.analytics = false
|
27
27
|
config.queue = Sufia::Resque::Queue
|
28
28
|
config.max_notifications_for_dashboard = 5
|
29
|
+
config.activity_to_show_default_seconds_since_now = 24*60*60
|
30
|
+
|
31
|
+
# Defaulting analytic start date to when ever the file was uploaded by leaving it blank
|
32
|
+
config.analytic_start_date = nil
|
29
33
|
|
30
34
|
config.autoload_paths += %W(
|
31
35
|
#{config.root}/app/models/datastreams
|
data/lib/sufia/models/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Friesen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -339,6 +339,7 @@ files:
|
|
339
339
|
- lib/generators/sufia/models/templates/config/mime_types.rb
|
340
340
|
- lib/generators/sufia/models/templates/config/redis.yml
|
341
341
|
- lib/generators/sufia/models/templates/config/redis_config.rb
|
342
|
+
- lib/generators/sufia/models/templates/config/resque-pool.yml
|
342
343
|
- lib/generators/sufia/models/templates/config/resque_admin.rb
|
343
344
|
- lib/generators/sufia/models/templates/config/resque_config.rb
|
344
345
|
- lib/generators/sufia/models/templates/config/setup_mail.rb
|