<commit_before>module Notify
  class MailableNotifications
    attr_reader :frequency

    def initialize frequency
      @frequency = frequency.to_s
    end

    def send_emails
      send_digests
      send_notifications
    end

    def send_digests
      digestible_notifications = notifications.digestible

      if (digestible_notifications).length > 0
        Notify::Jobs::NotificationsDigestEmail.new(
          digestible_notifications
        ).notify
      end
    end

    def send_notifications
      notifications.not_digestible.each do |notification|
        Notify::Jobs::NotificationEmail.new(notification).notify
      end
    end

    private

    def notifications
      @notifications ||= Notify::Notification::Base
        .includes(recipient: :notification_frequency)
        .where(notify_notification_frequencies: { value: frequency })
        .unread
        .not_emailed
    end
  end
end<commit_msg>Adds exception_notification<commit_after>module Notify
  class MailableNotifications
    attr_reader :frequency

    def initialize frequency
      @frequency = frequency.to_s
    end

    def send_emails
      begin
        send_digests
        send_notifications
      rescue => exception
        ExceptionNotifier.notify_exception(e)
      end
    end

    def send_digests
      digestible_notifications = notifications.digestible

      if (digestible_notifications).length > 0
        Notify::Jobs::NotificationsDigestEmail.new(
          digestible_notifications
        ).notify
      end
    end

    def send_notifications
      notifications.not_digestible.each do |notification|
        Notify::Jobs::NotificationEmail.new(notification).notify
      end
    end

    private

    def notifications
      @notifications ||= Notify::Notification::Base
        .includes(recipient: :notification_frequency)
        .where(notify_notification_frequencies: { value: frequency })
        .unread
        .not_emailed
    end
  end
end

{'fraction_non_alphanumeric': 0.05840528186896902, 'fraction_numerical': 0.001015744032503809, 'mean_word_length': 2.6617100371747213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5814279', 'n_tokens_mistral': 547, 'n_tokens_neox': 515, 'n_words': 109}