<commit_before># -*- coding: utf-8 -*-

class TitlePlugin < Plugin
  def before_handler
    return if current_user.blank?

    title = []

    if uconf('show_unread_notifications_in_title', 'no') == 'yes'
      notifications = get('new_notifications') || []
      title << notifications.length.to_s
    end

    if uconf('show_unread_pms_in_title', 'no') == 'yes'
      priv_msgs = CfPrivMessage.where(owner_id: current_user.user_id, is_read: false).count
      title << priv_msgs.to_s
    end

    if uconf('show_new_messages_since_last_visit_in_title', 'no') == 'yes' and not current_user.last_sign_in_at.blank?
      cnt = CfMessage.select('count(*) AS cnt').
        joins("LEFT JOIN read_messages ON read_messages.message_id = messages.message_id AND read_messages.user_id = " + current_user.user_id.to_s).
        where('forum_id IN (?) AND read_messages.message_id IS NULL AND messages.created_at > ?',
              @app_controller.get('forums').map { |f| f.forum_id }, current_user.last_sign_in_at).all

      title << cnt[0].cnt
    end<commit_msg>fix: do not count deleted messages<commit_after># -*- coding: utf-8 -*-

class TitlePlugin < Plugin
  def before_handler
    return if current_user.blank?

    title = []

    if uconf('show_unread_notifications_in_title', 'no') == 'yes'
      notifications = get('new_notifications') || []
      title << notifications.length.to_s
    end

    if uconf('show_unread_pms_in_title', 'no') == 'yes'
      priv_msgs = CfPrivMessage.where(owner_id: current_user.user_id, is_read: false).count
      title << priv_msgs.to_s
    end

    if uconf('show_new_messages_since_last_visit_in_title', 'no') == 'yes' and not current_user.last_sign_in_at.blank?
      cnt = CfMessage.select('count(*) AS cnt').
        joins("LEFT JOIN read_messages ON read_messages.message_id = messages.message_id AND read_messages.user_id = " + current_user.user_id.to_s).
        where('forum_id IN (?) AND read_messages.message_id IS NULL AND messages.created_at > ? AND deleted = false',
              @app_controller.get('forums').map { |f| f.forum_id }, current_user.last_sign_in_at).all

      title << cnt[0].cnt
    end
{'fraction_non_alphanumeric': 0.12517385257301808, 'fraction_numerical': 0.0018544274455261937, 'mean_word_length': 3.630901287553648, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 5, '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': '129433', 'n_tokens_mistral': 741, 'n_tokens_neox': 720, 'n_words': 143}