<commit_before>require File.dirname(__FILE__) + '/support/setup'

# A background job to update all child models with the correct access level
# of the parent document, and update all assets on S3.
class UpdateAccess < CloudCrowd::Action

  def process
    begin
      ActiveRecord::Base.establish_connection
      access   = options['access']
      document = Document.find(input)
      attrs    = { :access => access, :document_id => document.id }
      Page.update_all(attrs)
      Entity.update_all(attrs)
      EntityDate.update_all(attrs)
      DC::Store::AssetStore.new.set_access(document, access)
      document.update_attributes(:access => access)
    rescue Exception => e
      LifecycleMailer.exception_notification(e,options).deliver
      document.update_attributes(:access => DC::Access::ERROR) if document
      raise e
    end
    true
  end

end<commit_msg>Fix update_access action.<commit_after>require File.dirname(__FILE__) + '/support/setup'

# A background job to update all child models with the correct access level
# of the parent document, and update all assets on S3.
class UpdateAccess < CloudCrowd::Action

  def process
    begin
      ActiveRecord::Base.establish_connection
      access   = options['access']
      document = Document.find(input)
      [Page, Entity, EntityDate].each{ |model_klass| model_klass.where(:document_id => document.id).update_all(:access=>access) }
      DC::Store::AssetStore.new.set_access(document, access)
      document.update_attributes(:access => access)
    rescue Exception => e
      LifecycleMailer.exception_notification(e,options).deliver
      document.update_attributes(:access => DC::Access::ERROR) if document
      raise e
    end
    true
  end

end
{'fraction_non_alphanumeric': 0.09658762290341237, 'fraction_numerical': 0.001156737998843262, 'mean_word_length': 3.7790055248618786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2617179', 'n_tokens_mistral': 476, 'n_tokens_neox': 473, 'n_words': 125}