<commit_before>module Services
  class ProcessDocCollection < Services::Base
    def call(doc_collection_id)
      doc_collection = DocCollection.where(id: doc_collection_id).first
      raise Error, "Doc collection with ID #{doc_collection_id} not found." if doc_collection.nil?

      # Create files for docs
      doc_collection.docs.each do |doc|
        begin
          Services::Docs::CreateFiles.call doc
        rescue Services::Docs::CreateFiles::CreatingInProgressError
          self.class.perform_in 1.minute, doc_collection_id
          return
        rescue Services::Docs::CreateFiles::FilesExistsError
          next
        end
      end

      # Create doc collection files
      Services::DocCollections::CreateFiles.call doc_collection

      # Set generated_at timestamp
      doc_collection.generated_at = Time.now
      doc_collection.save!

      # Send notifications
      emails = EmailNotification.by_doc_collection(doc_collection).map(&:email)
      Mailer.doc_collection_generated(doc_collection, emails).deliver! if emails.present?
<commit_msg>Add TODO<commit_after>module Services
  class ProcessDocCollection < Services::Base
    def call(doc_collection_id)
      doc_collection = DocCollection.where(id: doc_collection_id).first
      raise Error, "Doc collection with ID #{doc_collection_id} not found." if doc_collection.nil?

      # Create files for docs
      doc_collection.docs.each do |doc|
        begin
          Services::Docs::CreateFiles.call doc
        rescue Services::Docs::CreateFiles::CreatingInProgressError
          self.class.perform_in 1.minute, doc_collection_id
          return
        rescue Services::Docs::CreateFiles::FilesExistsError
          next
        end
      end

      # Create doc collection files
      Services::DocCollections::CreateFiles.call doc_collection

      # Set generated_at timestamp
      doc_collection.generated_at = Time.now
      doc_collection.save!

      # Send notifications
      emails = EmailNotification.by_doc_collection(doc_collection).map(&:email)
      Mailer.doc_collection_generated(doc_collection, emails).deliver! if emails.present?
      # TODO: Delete email notifications

{'fraction_non_alphanumeric': 0.07326007326007326, 'fraction_numerical': 0.0009157509157509158, 'mean_word_length': 3.275929549902153, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5386370', 'n_tokens_mistral': 577, 'n_tokens_neox': 565, 'n_words': 129}