<commit_before>class UsersController < ApplicationController
  include WithUserParams

  before_action :authenticate!, except: :terms
  before_action :set_user!
  skip_before_action :validate_accepted_role_terms!

  def update
    current_user.update_and_notify! user_params
    current_user.accept_profile_terms!
    flash.notice = I18n.t(:user_data_updated)
    redirect_after! :profile_completion, fallback_location: user_path
  end

  def accept_profile_terms
    current_user.accept_profile_terms!
    flash.notice = I18n.t(:terms_accepted)
    redirect_after! :terms_acceptance, fallback_location: root_path
  end

  def terms
    @profile_terms ||= Term.profile_terms_for(current_user)
  end

  def messages
    @messages ||= current_user.messages_in_organization
  end

  def discussions
    @watched_discussions = current_user.watched_discussions_in_organization.scoped_query_by(discussion_filter_params)
  end

  def activity
    @activity = UserStats.stats_for(current_user).activity date_range_params
  end

  def certificates
    @certificates ||= current_user.certificates_in_organization
  end

  def exam_authorizations
    @exam_authorization_requests ||= ExamAuthorizationRequest.where(user: current_user, organization: Organization.current)
  end

  def unsubscribe
    user_id = User.unsubscription_verifier.verify(params[:id])
    User.find(user_id).unsubscribe_from_reminders!

    redirect_to root_path, notice: t(:unsubscribed_successfully)
  end

  def permissible_params
    super << [:avatar_id, :avatar_type]
  end<commit_msg>Show unread discussions first on profile<commit_after>class UsersController < ApplicationController
  include WithUserParams

  before_action :authenticate!, except: :terms
  before_action :set_user!
  skip_before_action :validate_accepted_role_terms!

  def update
    current_user.update_and_notify! user_params
    current_user.accept_profile_terms!
    flash.notice = I18n.t(:user_data_updated)
    redirect_after! :profile_completion, fallback_location: user_path
  end

  def accept_profile_terms
    current_user.accept_profile_terms!
    flash.notice = I18n.t(:terms_accepted)
    redirect_after! :terms_acceptance, fallback_location: root_path
  end

  def terms
    @profile_terms ||= Term.profile_terms_for(current_user)
  end

  def messages
    @messages ||= current_user.messages_in_organization
  end

  def discussions
    @watched_discussions = current_user.watched_discussions_in_organization.scoped_query_by(discussion_filter_params).unread_first
  end

  def activity
    @activity = UserStats.stats_for(current_user).activity date_range_params
  end

  def certificates
    @certificates ||= current_user.certificates_in_organization
  end

  def exam_authorizations
    @exam_authorization_requests ||= ExamAuthorizationRequest.where(user: current_user, organization: Organization.current)
  end

  def unsubscribe
    user_id = User.unsubscription_verifier.verify(params[:id])
    User.find(user_id).unsubscribe_from_reminders!

    redirect_to root_path, notice: t(:unsubscribed_successfully)
  end

  def permissible_params
    super << [:avatar_id, :avatar_type]
  end
{'fraction_non_alphanumeric': 0.06639135959339262, 'fraction_numerical': 0.0025412960609911056, 'mean_word_length': 5.387423935091278, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1193503', 'n_tokens_mistral': 1021, 'n_tokens_neox': 954, 'n_words': 174}