<commit_before>class UsersController < ApplicationController
  before_action :set_user, only: [:edit, :update, :change_identity]
  before_action :verify_name, only: :show

  def index
    authorize User
    @students = User.includes(:memberships).includes(avatar_attachment: :blob).where(memberships: { course: Course.current, role: :student })

    # Just for massive actions
    @lectures = Lecture.all.order(date: :asc)
    @teams = Team.all.order(name: :asc)
    @badges = Badge.all
    @events = Event.all.order(name: :asc) - [Course.current.attendance_event]
    @score_calculator = ScoreCalculator.new

    respond_to do |format|
      format.html
      format.csv do
        send_data User.to_csv, filename: "attendance_sheet.csv"
      end
    end
  end

  def show
    if params[:nickname]
      unless @user = Course.current.memberships.includes(:user).find_by(users: { nickname: params[:nickname] }).try(:user)
        flash[:alert] = "No existe el usuario"
        return redirect_to "/"
      end
    else
      @user = current_user
    end
    @missing_badges = Badge.all - @user.badges
    authorize @user
  end

  def demote
    user = User.find(params[:id])
    authorize current_user, :promote?
    user.current_membership.update(role: :student)
    flash[:info] = "#{user.full_name} fue degradado a Estudiante"
    redirect_to students_path
  end

  def comment
    unless @user = Course.current.memberships.includes(:user).find_by(users: { nickname: params[:nickname] }).try(:user)<commit_msg>Chore: changed redirection after teacher demotion<commit_after>class UsersController < ApplicationController
  before_action :set_user, only: [:edit, :update, :change_identity]
  before_action :verify_name, only: :show

  def index
    authorize User
    @students = User.includes(:memberships).includes(avatar_attachment: :blob).where(memberships: { course: Course.current, role: :student })

    # Just for massive actions
    @lectures = Lecture.all.order(date: :asc)
    @teams = Team.all.order(name: :asc)
    @badges = Badge.all
    @events = Event.all.order(name: :asc) - [Course.current.attendance_event]
    @score_calculator = ScoreCalculator.new

    respond_to do |format|
      format.html
      format.csv do
        send_data User.to_csv, filename: "attendance_sheet.csv"
      end
    end
  end

  def show
    if params[:nickname]
      unless @user = Course.current.memberships.includes(:user).find_by(users: { nickname: params[:nickname] }).try(:user)
        flash[:alert] = "No existe el usuario"
        return redirect_to "/"
      end
    else
      @user = current_user
    end
    @missing_badges = Badge.all - @user.badges
    authorize @user
  end

  def demote
    user = User.find(params[:id])
    authorize current_user, :promote?
    user.current_membership.update(role: :student)
    flash[:info] = "#{user.full_name} fue degradado a Estudiante"
    redirect_to teachers_path
  end

  def comment
    unless @user = Course.current.memberships.includes(:user).find_by(users: { nickname: params[:nickname] }).try(:user)
{'fraction_non_alphanumeric': 0.11586161879895561, 'fraction_numerical': 0.0, 'mean_word_length': 3.5340236686390534, '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': '5918441', 'n_tokens_mistral': 996, 'n_tokens_neox': 966, 'n_words': 222}