<commit_before>class UsersController < ApplicationController
  skip_before_action :admin_only, only: [:show]
  before_action :correct_user_only
  before_action :is_archived, only: [:show]

  def index
    # We create 2 grids, one for normal usage and one to be used for download
    @users_grid = UsersGrid.new(params[:users_grid])
    @users_grid_csv = UsersGrid.new(params[:users_grid])
    respond_to do |f|
      f.html do
        # Display the first grid as normal
        @users_grid.scope { |scope| scope.page(params[:page]) }
      end
      f.csv do
        # Send the second grid to csv format and allow to be downloaded
        send_data @users_grid_csv.to_csv,
          type: "text/csv",
          disposition: 'inline',
          filename: "users-#{Time.now.to_s}.csv"
      end
    end
  end

  def show
    @user = User.find(params[:id])
    funder_ids = Array.new
    @user.user_funders.each do |funder|
      funder_ids.push(funder.funder_id)
    end
    @enrolments_grid = EnrolmentsInUsersGrid.new(params[:enrolments_grid]) { |scope| scope.where(:id => @user.enrolments) }
    @unenrolments_grid = UnenrolmentsInUsersGrid.new(params[:unenrolments_grid]) { |scope| scope.where(:id => @user.unenrolments) }
    @feedbacks_grid = FeedbacksGrid.new(params[:feedbacks_grid]) { |scope| scope.where(:id => @user.feedbacks.ids) }
    @conditions_grid = ConditionsGrid.new(params[:conditions_grid]) { |scope| scope.where(:id => @user.conditions.ids) }<commit_msg>Add all archive checking for users controller.<commit_after>class UsersController < ApplicationController
  skip_before_action :admin_only, only: [:show]
  before_action :correct_user_only
  before_action :is_archived, only: [:show]

  def index
    # We create 2 grids, one for normal usage and one to be used for download
    @users_grid = UsersGrid.new(params[:users_grid]) { |scope| scope.where(:archived => false) }
    @users_grid_csv = UsersGrid.new(params[:users_grid]) { |scope| scope.where(:archived => false) }
    respond_to do |f|
      f.html do
        # Display the first grid as normal
        @users_grid.scope { |scope| scope.page(params[:page]) }
      end
      f.csv do
        # Send the second grid to csv format and allow to be downloaded
        send_data @users_grid_csv.to_csv,
          type: "text/csv",
          disposition: 'inline',
          filename: "users-#{Time.now.to_s}.csv"
      end
    end
  end

  def show
    @user = User.find(params[:id])
    funder_ids = Array.new
    @user.user_funders.each do |funder|
      funder_ids.push(funder.funder_id)
    end
    @enrolments_grid = EnrolmentsInUsersGrid.new(params[:enrolments_grid]) { |scope| scope.where(:id => @user.enrolments) }
    @unenrolments_grid = UnenrolmentsInUsersGrid.new(params[:unenrolments_grid]) { |scope| scope.where(:id => @user.unenrolments) }
    @feedbacks_grid = FeedbacksGrid.new(params[:feedbacks_grid]) { |scope| scope.where(:id => @user.feedbacks.ids) }
    @conditions_grid = ConditionsGrid.new(params[:conditions_grid]) { |scope| scope.where(:id => @user.conditions.ids) }
{'fraction_non_alphanumeric': 0.12153796024763766, 'fraction_numerical': 0.0006516780710329097, 'mean_word_length': 3.6374622356495467, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1781604', 'n_tokens_mistral': 1013, 'n_tokens_neox': 998, 'n_words': 222}