sufia-models 6.2.0 → 6.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/actors/sufia/generic_file/actor.rb +4 -7
  3. data/app/jobs/active_fedora_id_based_job.rb +1 -1
  4. data/app/jobs/active_fedora_pid_based_job.rb +1 -2
  5. data/app/jobs/audit_job.rb +1 -1
  6. data/app/jobs/batch_update_job.rb +6 -6
  7. data/app/jobs/create_derivatives_job.rb +2 -3
  8. data/app/jobs/import_url_job.rb +8 -5
  9. data/app/jobs/ingest_local_file_job.rb +1 -1
  10. data/app/models/batch.rb +15 -21
  11. data/app/models/checksum_audit_log.rb +0 -1
  12. data/app/models/concerns/sufia/ability.rb +5 -0
  13. data/app/models/concerns/sufia/collection_behavior.rb +3 -2
  14. data/app/models/concerns/sufia/file_stat_utils.rb +19 -21
  15. data/app/models/concerns/sufia/generic_file/batches.rb +1 -3
  16. data/app/models/concerns/sufia/generic_file/characterization.rb +11 -16
  17. data/app/models/concerns/sufia/generic_file/content.rb +0 -1
  18. data/app/models/concerns/sufia/generic_file/derivatives.rb +2 -2
  19. data/app/models/concerns/sufia/generic_file/export.rb +50 -59
  20. data/app/models/concerns/sufia/generic_file/full_text_indexing.rb +15 -18
  21. data/app/models/concerns/sufia/generic_file/metadata.rb +0 -2
  22. data/app/models/concerns/sufia/generic_file/mime_types.rb +9 -9
  23. data/app/models/concerns/sufia/generic_file/permissions.rb +0 -1
  24. data/app/models/concerns/sufia/generic_file/proxy_deposit.rb +0 -1
  25. data/app/models/concerns/sufia/generic_file/querying.rb +9 -5
  26. data/app/models/concerns/sufia/generic_file/trophies.rb +1 -1
  27. data/app/models/concerns/sufia/generic_file/versions.rb +0 -4
  28. data/app/models/concerns/sufia/model_methods.rb +0 -1
  29. data/app/models/concerns/sufia/user.rb +15 -15
  30. data/app/models/concerns/sufia/user_usage_stats.rb +0 -2
  31. data/app/models/datastreams/fits_datastream.rb +25 -25
  32. data/app/models/domain_term.rb +2 -3
  33. data/app/models/featured_work.rb +3 -5
  34. data/app/models/file_download_stat.rb +3 -4
  35. data/app/models/file_usage.rb +10 -11
  36. data/app/models/file_view_stat.rb +3 -3
  37. data/app/models/follow.rb +1 -1
  38. data/app/models/geo_names_resource.rb +3 -3
  39. data/app/models/group.rb +1 -3
  40. data/app/models/local_authority.rb +26 -28
  41. data/app/models/proxy_deposit_request.rb +9 -9
  42. data/app/models/single_use_link.rb +10 -18
  43. data/app/models/sufia/download.rb +2 -2
  44. data/app/models/sufia/pageview.rb +1 -1
  45. data/app/models/trophy.rb +2 -4
  46. data/app/services/sufia/analytics.rb +10 -11
  47. data/app/services/sufia/generic_file_audit_service.rb +11 -12
  48. data/app/services/sufia/repository_audit_service.rb +1 -1
  49. data/config/locales/sufia.en.yml +2 -0
  50. data/lib/generators/sufia/models/abstract_migration_generator.rb +7 -6
  51. data/lib/generators/sufia/models/install_generator.rb +3 -3
  52. data/lib/generators/sufia/models/templates/config/arkivo_constraint.rb +1 -1
  53. data/lib/generators/sufia/models/templates/config/clamav.rb +1 -1
  54. data/lib/generators/sufia/models/templates/config/redis_config.rb +13 -5
  55. data/lib/generators/sufia/models/templates/config/resque_admin.rb +2 -2
  56. data/lib/generators/sufia/models/templates/config/resque_config.rb +1 -1
  57. data/lib/generators/sufia/models/templates/config/sufia.rb +10 -4
  58. data/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +1 -1
  59. data/lib/generators/sufia/models/templates/migrations/create_file_download_stats.rb +1 -1
  60. data/lib/generators/sufia/models/templates/migrations/create_file_view_stats.rb +1 -1
  61. data/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +1 -1
  62. data/lib/generators/sufia/models/update_content_blocks_generator.rb +0 -1
  63. data/lib/generators/sufia/models/upgrade600_generator.rb +0 -1
  64. data/lib/generators/sufia/models/user_stats_generator.rb +2 -2
  65. data/lib/sufia/messages.rb +17 -17
  66. data/lib/sufia/models.rb +1 -1
  67. data/lib/sufia/models/active_fedora/redis.rb +1 -4
  68. data/lib/sufia/models/active_record/redis.rb +2 -3
  69. data/lib/sufia/models/engine.rb +12 -7
  70. data/lib/sufia/models/file_content/versions.rb +0 -1
  71. data/lib/sufia/models/resque.rb +2 -2
  72. data/lib/sufia/models/stats/user_stat_importer.rb +65 -67
  73. data/lib/sufia/models/user_local_directory_behavior.rb +9 -13
  74. data/lib/sufia/models/utils.rb +1 -2
  75. data/lib/sufia/models/version.rb +1 -1
  76. data/lib/sufia/permissions.rb +0 -1
  77. data/lib/sufia/permissions/readable.rb +0 -1
  78. data/lib/sufia/permissions/writable.rb +20 -23
  79. data/lib/tasks/sufia-models_tasks.rake +18 -0
  80. data/sufia-models.gemspec +1 -1
  81. metadata +5 -5
@@ -2,17 +2,16 @@ class FileDownloadStat < ActiveRecord::Base
2
2
  extend Sufia::FileStatUtils
3
3
 
4
4
  def to_flot
5
- [ self.class.convert_date(date), downloads ]
5
+ [self.class.convert_date(date), downloads]
6
6
  end
7
7
 
8
- def self.statistics file_id, start_date, user_id=nil
8
+ def self.statistics(file_id, start_date, user_id = nil)
9
9
  combined_stats file_id, start_date, :downloads, :totalEvents, user_id
10
10
  end
11
11
 
12
12
  # Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
13
13
  # see Legato::ProfileMethods.method_name_from_klass
14
- def self.ga_statistics start_date, file_id
14
+ def self.ga_statistics(start_date, file_id)
15
15
  Sufia::Analytics.profile.sufia__download(sort: 'date', start_date: start_date, end_date: Date.yesterday).for_file(file_id)
16
16
  end
17
-
18
17
  end
@@ -1,8 +1,7 @@
1
1
  class FileUsage
2
-
3
2
  attr_accessor :id, :created, :path, :downloads, :pageviews
4
3
 
5
- def initialize id
4
+ def initialize(id)
6
5
  file = ::GenericFile.find(id)
7
6
  user = User.where(email: file.depositor).first
8
7
  user_id = user ? user.id : nil
@@ -14,31 +13,31 @@ class FileUsage
14
13
  self.pageviews = FileViewStat.to_flots FileViewStat.statistics(id, created, user_id)
15
14
  end
16
15
 
17
- # file.date_uploaded reflects the date the file was uploaded by the user
18
- # and therefore (if available) the date that we want to use for the stats
19
- # file.create_date reflects the date the file was added to Fedora. On data
20
- # migrated from one repository to another the created_date can be later
16
+ # file.date_uploaded reflects the date the file was uploaded by the user
17
+ # and therefore (if available) the date that we want to use for the stats
18
+ # file.create_date reflects the date the file was added to Fedora. On data
19
+ # migrated from one repository to another the created_date can be later
21
20
  # than the date the file was uploaded.
22
- def date_for_analytics(file)
21
+ def date_for_analytics(file)
23
22
  earliest = Sufia.config.analytic_start_date
24
23
  date_uploaded = string_to_date file.date_uploaded
25
24
  date_analytics = date_uploaded ? date_uploaded : file.create_date
26
25
  return date_analytics if earliest.blank?
27
- earliest > date_analytics ? earliest : date_analytics
26
+ earliest > date_analytics ? earliest : date_analytics
28
27
  end
29
28
 
30
29
  def string_to_date(date_str)
31
- return DateTime.parse(date_str)
30
+ return DateTime.parse(date_str)
32
31
  rescue ArgumentError, TypeError
33
32
  return nil
34
33
  end
35
34
 
36
35
  def total_downloads
37
- self.downloads.reduce(0) { |total, result| total + result[1].to_i }
36
+ downloads.reduce(0) { |total, result| total + result[1].to_i }
38
37
  end
39
38
 
40
39
  def total_pageviews
41
- self.pageviews.reduce(0) { |total, result| total + result[1].to_i }
40
+ pageviews.reduce(0) { |total, result| total + result[1].to_i }
42
41
  end
43
42
 
44
43
  # Package data for visualization using JQuery Flot
@@ -2,16 +2,16 @@ class FileViewStat < ActiveRecord::Base
2
2
  extend Sufia::FileStatUtils
3
3
 
4
4
  def to_flot
5
- [ self.class.convert_date(date), views ]
5
+ [self.class.convert_date(date), views]
6
6
  end
7
7
 
8
- def self.statistics file_id, start_date, user_id=nil
8
+ def self.statistics(file_id, start_date, user_id = nil)
9
9
  combined_stats file_id, start_date, :views, :pageviews, user_id
10
10
  end
11
11
 
12
12
  # Sufia::Download is sent to Sufia::Analytics.profile as #sufia__download
13
13
  # see Legato::ProfileMethods.method_name_from_klass
14
- def self.ga_statistics start_date, file_id
14
+ def self.ga_statistics(start_date, file_id)
15
15
  path = Sufia::Engine.routes.url_helpers.generic_file_path(file_id)
16
16
  Sufia::Analytics.profile.sufia__pageview(sort: 'date', start_date: start_date).for_path(path)
17
17
  end
data/app/models/follow.rb CHANGED
@@ -7,6 +7,6 @@ class Follow < ActiveRecord::Base
7
7
  belongs_to :follower, polymorphic: true
8
8
 
9
9
  def block!
10
- self.update_attribute(:blocked, true)
10
+ update_attribute(:blocked, true)
11
11
  end
12
12
  end
@@ -8,11 +8,11 @@ class GeoNamesResource < ActiveResource::Base
8
8
  end
9
9
 
10
10
  def self.instantiate_collection(collection, original_params = {}, prefix_options = {})
11
- col = super(collection["geonames"], original_params, prefix_options)
12
- col.map! { |item| { label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName} }
11
+ col = super(collection["geonames"], original_params, prefix_options)
12
+ col.map! { |item| { label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName, value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName } }
13
13
  end
14
14
 
15
15
  def self.find_location(location)
16
- return GeoNamesResource.find(:all, params: { q: location, username: "cam156", maxRows: 10})
16
+ GeoNamesResource.find(:all, params: { q: location, username: "cam156", maxRows: 10 })
17
17
  end
18
18
  end
data/app/models/group.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  ## This could extend from a module that would make it an ldap group
2
2
  class Group
3
-
4
- def self.exists?(cn)
3
+ def self.exists?(_cn)
5
4
  false
6
5
  end
7
-
8
6
  end
@@ -1,37 +1,35 @@
1
1
  class LocalAuthority < ActiveRecord::Base
2
-
3
- # TODO we should add an index on this join table and remove the uniq query
2
+ # TODO: we should add an index on this join table and remove the uniq query
4
3
  has_and_belongs_to_many :domain_terms, -> { uniq }
5
-
4
+
6
5
  has_many :local_authority_entries
7
6
 
8
7
  def self.harvest_rdf(name, sources, opts = {})
9
- return unless self.where(name: name).empty?
10
- authority = self.create(name: name)
8
+ return unless where(name: name).empty?
9
+ authority = create(name: name)
11
10
  format = opts.fetch(:format, :ntriples)
12
11
  predicate = opts.fetch(:predicate, ::RDF::SKOS.prefLabel)
13
12
  entries = []
14
13
  sources.each do |uri|
15
14
  ::RDF::Reader.open(uri, format: format) do |reader|
16
15
  reader.each_statement do |statement|
17
- if statement.predicate == predicate
18
- entries << LocalAuthorityEntry.new(local_authority: authority,
19
- label: statement.object.to_s,
20
- uri: statement.subject.to_s)
21
- end
16
+ next unless statement.predicate == predicate
17
+ entries << LocalAuthorityEntry.new(local_authority: authority,
18
+ label: statement.object.to_s,
19
+ uri: statement.subject.to_s)
22
20
  end
23
21
  end
24
22
  end
25
23
  if LocalAuthorityEntry.respond_to? :import
26
24
  LocalAuthorityEntry.import entries
27
25
  else
28
- entries.each { |e| e.save! }
26
+ entries.each(&:save!)
29
27
  end
30
28
  end
31
29
 
32
30
  def self.harvest_tsv(name, sources, opts = {})
33
- return unless self.where(name: name).empty?
34
- authority = self.create(name: name)
31
+ return unless where(name: name).empty?
32
+ authority = create(name: name)
35
33
  prefix = opts.fetch(:prefix, "")
36
34
  entries = []
37
35
  sources.each do |uri|
@@ -47,12 +45,12 @@ class LocalAuthority < ActiveRecord::Base
47
45
  if LocalAuthorityEntry.respond_to? :import
48
46
  LocalAuthorityEntry.import entries
49
47
  else
50
- entries.each { |e| e.save! }
48
+ entries.each(&:save!)
51
49
  end
52
50
  end
53
51
 
54
52
  def self.register_vocabulary(model, term, name)
55
- authority = self.find_by_name(name)
53
+ authority = find_by_name(name)
56
54
  return if authority.blank?
57
55
  model = model.to_s.sub(/RdfDatastream$/, '').underscore.pluralize
58
56
  domain_term = DomainTerm.find_or_create_by(model: model, term: term)
@@ -62,25 +60,25 @@ class LocalAuthority < ActiveRecord::Base
62
60
 
63
61
  def self.entries_by_term(model, term, query)
64
62
  return if query.empty?
65
- lowQuery = query.downcase
63
+ low_query = query.downcase
66
64
  hits = []
67
- # move lc_subject into it's own table since being part of the usual structure caused it to be too slow.
68
- # When/if we move to having multiple dictionaries for subject we will need to also do a check for the appropriate dictionary.
69
- if (term == 'subject' && model == 'generic_files') # and local_authoritiy = lc_subject
70
- sql = SubjectLocalAuthorityEntry.where("lowerLabel like ?", "#{lowQuery}%").select("label, uri").limit(25).to_sql
71
- SubjectLocalAuthorityEntry.find_by_sql(sql).each do |hit|
72
- hits << {uri: hit.uri, label: hit.label}
73
- end
74
- else
65
+ # move lc_subject into it's own table since being part of the usual structure caused it to be too slow.
66
+ # When/if we move to having multiple dictionaries for subject we will need to also do a check for the appropriate dictionary.
67
+ if term == 'subject' && model == 'generic_files' # and local_authoritiy = lc_subject
68
+ sql = SubjectLocalAuthorityEntry.where("lowerLabel like ?", "#{low_query}%").select("label, uri").limit(25).to_sql
69
+ SubjectLocalAuthorityEntry.find_by_sql(sql).each do |hit|
70
+ hits << { uri: hit.uri, label: hit.label }
71
+ end
72
+ else
75
73
  dterm = DomainTerm.where(model: model, term: term).first
76
74
  if dterm
77
- authorities = dterm.local_authorities.collect(&:id).uniq
78
- sql = LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("lower(label) like ?", "#{lowQuery}%").select("label, uri").limit(25).to_sql
75
+ authorities = dterm.local_authorities.collect(&:id).uniq
76
+ sql = LocalAuthorityEntry.where("local_authority_id in (?)", authorities).where("lower(label) like ?", "#{low_query}%").select("label, uri").limit(25).to_sql
79
77
  LocalAuthorityEntry.find_by_sql(sql).each do |hit|
80
- hits << {uri: hit.uri, label: hit.label}
78
+ hits << { uri: hit.uri, label: hit.label }
81
79
  end
82
80
  end
83
81
  end
84
- return hits
82
+ hits
85
83
  end
86
84
  end
@@ -24,31 +24,31 @@ class ProxyDepositRequest < ActiveRecord::Base
24
24
  end
25
25
 
26
26
  def sending_user_should_not_be_receiving_user
27
- errors.add(:sending_user, 'must specify another user to receive the file') if receiving_user and receiving_user.user_key == sending_user.user_key
27
+ errors.add(:sending_user, 'must specify another user to receive the file') if receiving_user && receiving_user.user_key == sending_user.user_key
28
28
  end
29
29
 
30
30
  def should_not_be_already_part_of_a_transfer
31
31
  transfers = ProxyDepositRequest.where(generic_file_id: generic_file_id, status: 'pending')
32
- errors.add(:open_transfer, 'must close open transfer on the file before creating a new one') unless transfers.blank? || ( transfers.count == 1 && transfers[0].id == self.id)
32
+ errors.add(:open_transfer, 'must close open transfer on the file before creating a new one') unless transfers.blank? || (transfers.count == 1 && transfers[0].id == id)
33
33
  end
34
34
 
35
35
  def send_request_transfer_message
36
- if self.updated_at == self.created_at
36
+ if updated_at == created_at
37
37
  message = "#{link_to(sending_user.name, Sufia::Engine.routes.url_helpers.profile_path(sending_user.user_key))} wants to transfer a file to you. Review all <a href='#{Sufia::Engine.routes.url_helpers.transfers_path}'>transfer requests</a>"
38
38
  User.batchuser.send_message(receiving_user, message, "Ownership Change Request")
39
- else
40
- message = "Your transfer request was #{status}."
41
- message = message + " Comments: #{receiver_comment}" if !receiver_comment.blank?
42
- User.batchuser.send_message(sending_user, message, "Ownership Change #{status}")
39
+ else
40
+ message = "Your transfer request was #{status}."
41
+ message += " Comments: #{receiver_comment}" unless receiver_comment.blank?
42
+ User.batchuser.send_message(sending_user, message, "Ownership Change #{status}")
43
43
  end
44
44
  end
45
45
 
46
46
  def pending?
47
- self.status == 'pending'
47
+ status == 'pending'
48
48
  end
49
49
 
50
50
  def accepted?
51
- self.status == 'accepted'
51
+ status == 'accepted'
52
52
  end
53
53
 
54
54
  # @param [Boolean] reset (false) should the access controls be reset. This means revoking edit access from the depositor
@@ -1,42 +1,34 @@
1
1
  class SingleUseLink < ActiveRecord::Base
2
-
3
2
  validate :expiration_date_cannot_be_in_the_past
4
3
  validate :cannot_be_destroyed
5
4
 
6
5
  after_initialize :set_defaults
7
6
 
8
- def create_for_path path
9
- self.class.create itemId: itemId, path: path
7
+ def create_for_path(path)
8
+ self.class.create(itemId: itemId, path: path)
10
9
  end
11
10
 
12
11
  def expired?
13
12
  DateTime.now > expires
14
13
  end
15
14
 
16
-
17
15
  def to_param
18
16
  downloadKey
19
17
  end
20
18
 
21
19
  protected
22
20
 
23
- def expiration_date_cannot_be_in_the_past
24
- if expired?
25
- errors.add(:expires, "can't be in the past")
21
+ def expiration_date_cannot_be_in_the_past
22
+ errors.add(:expires, "can't be in the past") if expired?
26
23
  end
27
- end
28
24
 
29
- def cannot_be_destroyed
30
- if destroyed?
31
- errors[:base] << "Single Use Link has already been used"
25
+ def cannot_be_destroyed
26
+ errors[:base] << "Single Use Link has already been used" if destroyed?
32
27
  end
33
- end
34
28
 
35
- def set_defaults
36
- if new_record?
37
- self.expires ||= DateTime.now.advance(hours:24)
38
- self.downloadKey ||= (Digest::SHA2.new << rand(1000000000).to_s).to_s
29
+ def set_defaults
30
+ return unless new_record?
31
+ self.expires ||= DateTime.now.advance(hours: 24)
32
+ self.downloadKey ||= (Digest::SHA2.new << rand(1_000_000_000).to_s).to_s
39
33
  end
40
- end
41
-
42
34
  end
@@ -4,6 +4,6 @@ module Sufia
4
4
 
5
5
  metrics :totalEvents
6
6
  dimensions :eventCategory, :eventAction, :eventLabel, :date
7
- filter :for_file, &lambda {|id| matches(:eventLabel, id)}
8
- end
7
+ filter :for_file, &->(id) { matches(:eventLabel, id) }
8
+ end
9
9
  end
@@ -4,6 +4,6 @@ module Sufia
4
4
 
5
5
  metrics :pageviews
6
6
  dimensions :date
7
- filter :for_path, &lambda { |path| contains(:pagePath, path) }
7
+ filter :for_path, &->(path) { contains(:pagePath, path) }
8
8
  end
9
9
  end
data/app/models/trophy.rb CHANGED
@@ -2,9 +2,7 @@ class Trophy < ActiveRecord::Base
2
2
  validate :count_within_limit, on: :create
3
3
 
4
4
  def count_within_limit
5
- if Trophy.where(user_id:self.user_id).count >= 5
6
- errors.add(:base, "Exceeded trophy limit")
7
- end
5
+ return if Trophy.where(user_id: user_id).count < 5
6
+ errors.add(:base, "Exceeded trophy limit")
8
7
  end
9
8
  end
10
-
@@ -20,29 +20,28 @@ module Sufia
20
20
  # @return [OAuth2::AccessToken] An OAuth2 access token for GA
21
21
  def self.token
22
22
  scope = 'https://www.googleapis.com/auth/analytics.readonly'
23
- client = Google::APIClient.new(application_name: self.config['app_name'],
24
- application_version: self.config['app_version'])
25
- key = Google::APIClient::PKCS12.load_key(self.config['privkey_path'],
26
- self.config['privkey_secret'])
27
- service_account = Google::APIClient::JWTAsserter.new(self.config['client_email'], scope,
28
- key)
23
+ client = Google::APIClient.new(application_name: config['app_name'],
24
+ application_version: config['app_version'])
25
+ key = Google::APIClient::PKCS12.load_key(config['privkey_path'],
26
+ config['privkey_secret'])
27
+ service_account = Google::APIClient::JWTAsserter.new(config['client_email'], scope,
28
+ key)
29
29
  client.authorization = service_account.authorize
30
- oauth_client = OAuth2::Client.new('', '', {
31
- authorize_url: 'https://accounts.google.com/o/oauth2/auth',
32
- token_url: 'https://accounts.google.com/o/oauth2/token'})
30
+ oauth_client = OAuth2::Client.new('', '', authorize_url: 'https://accounts.google.com/o/oauth2/auth',
31
+ token_url: 'https://accounts.google.com/o/oauth2/token')
33
32
  OAuth2::AccessToken.new(oauth_client, client.authorization.access_token)
34
33
  end
35
34
 
36
35
  # Return a user object linked to a Google Analytics account
37
36
  # @return [Legato::User] A user account wit GA access
38
37
  def self.user
39
- Legato::User.new(self.token)
38
+ Legato::User.new(token)
40
39
  end
41
40
 
42
41
  # Return a Google Analytics profile matching specified ID
43
42
  # @ return [Legato::Management::Profile] A user profile associated with GA
44
43
  def self.profile
45
- self.user.profiles.detect do |profile|
44
+ user.profiles.detect do |profile|
46
45
  profile.web_property_id == Sufia.config.google_analytics_id
47
46
  end
48
47
  end
@@ -11,12 +11,12 @@ module Sufia
11
11
  def human_readable_audit_status
12
12
  stat = audit_stat
13
13
  case stat
14
- when 0
15
- 'failing'
16
- when 1
17
- 'passing'
18
- else
19
- stat
14
+ when 0
15
+ 'failing'
16
+ when 1
17
+ 'passing'
18
+ else
19
+ stat
20
20
  end
21
21
  end
22
22
 
@@ -27,8 +27,8 @@ module Sufia
27
27
  audit_content([])
28
28
  end
29
29
 
30
-
31
30
  private
31
+
32
32
  def audit_content(log)
33
33
  if generic_file.content.has_versions?
34
34
  audit_file_versions("content", log)
@@ -37,9 +37,9 @@ module Sufia
37
37
  end
38
38
  end
39
39
 
40
- def audit_file_versions file, log
40
+ def audit_file_versions(file, log)
41
41
  generic_file.attached_files[file].versions.all.each do |version|
42
- log << audit_file(file, version.uri, version.label)
42
+ log << audit_file(file, version.uri, version.label)
43
43
  end
44
44
  log
45
45
  end
@@ -59,7 +59,7 @@ module Sufia
59
59
  audit_results = audit.collect { |result| result["pass"] }
60
60
 
61
61
  # check how many non runs we had
62
- non_runs = audit_results.reduce(0) { |sum, value| value == NO_RUNS ? sum += 1 : sum }
62
+ non_runs = audit_results.reduce(0) { |sum, value| value == NO_RUNS ? sum + 1 : sum }
63
63
  if non_runs == 0
64
64
  audit_results.reduce(true) { |sum, value| sum && value }
65
65
  elsif non_runs < audit_results.length
@@ -76,7 +76,7 @@ module Sufia
76
76
  def audit_stat_by_id
77
77
  audit_results = ChecksumAuditLog.logs_for(generic_file.id, "content").collect { |result| result["pass"] }
78
78
 
79
- if audit_results.length > 0
79
+ if audit_results.length > 0
80
80
  audit_results.reduce(true) { |sum, value| sum && value }
81
81
  else
82
82
  'Audits have not yet been run on this file.'
@@ -102,6 +102,5 @@ module Sufia
102
102
  def days_since_last_audit(latest_audit)
103
103
  (DateTime.now - latest_audit.updated_at.to_date).to_i
104
104
  end
105
-
106
105
  end
107
106
  end