<commit_before>class StuffController < ApplicationController
  load_and_authorize_resource
  handles_sortable_columns
  before_filter :no_sidebar
  def no_sidebar
    @skip_sidebar = true
  end
  # GET /stuff
  # GET /stuff.xml
  def index
    params[:sort] ||= 'name'
    order = sortable_column_order do |column, direction|
      case column
      when "name"
        "lower(#{column}) #{direction}"
      when "created_at", "updated_at", "location_id", "in_place"
        "#{column} #{direction}, name ASC"
      else
        "name DESC"
      end
    end
    @stuff = Stuff.order(order).includes(:location)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @stuff }
    end
  end

  def log
    @stuff = Stuff.find(:first, :conditions => [ 'lower(name) = ?', params[:stuff_name].strip.downcase ])
    unless @stuff
      @stuff = Stuff.create(:name => params[:stuff_name].strip)
    end
    @location = Stuff.get_location(params[:location_name])
    @stuff.location = @location
    logger.info "Stuff: #{@stuff.id}"
    logger.info "Location: #{@location.id}"
    logger.info "New location: #{@stuff.location.id}"
    logger.info "New location: #{@stuff.location.id}"
    result = @stuff.save!
    redirect_to params[:destination] || stuff_index_path, :notice => (result ? 'Logged' : 'Problem?') and return
  end
  # GET /stuff/1
  # GET /stuff/1.xml
  def show
    @stuff = Stuff.find(params[:id])
    @location_histories = @stuff.location_histories.order(:updated_at)
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @stuff }
    end<commit_msg>Stuff controller - filter by active<commit_after>class StuffController < ApplicationController
  load_and_authorize_resource
  handles_sortable_columns
  before_filter :no_sidebar
  def no_sidebar
    @skip_sidebar = true
  end
  # GET /stuff
  # GET /stuff.xml
  def index
    params[:sort] ||= 'name'
    order = sortable_column_order do |column, direction|
      case column
      when "name"
        "lower(#{column}) #{direction}"
      when "created_at", "updated_at", "location_id", "in_place"
        "#{column} #{direction}, name ASC"
      else
        "name DESC"
      end
    end
    @stuff = Stuff.where('status=?', 'active').order(order).includes(:location)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @stuff }
    end
  end

  def log
    @stuff = Stuff.find(:first, :conditions => [ 'lower(name) = ?', params[:stuff_name].strip.downcase ])
    unless @stuff
      @stuff = Stuff.create(:name => params[:stuff_name].strip)
    end
    @location = Stuff.get_location(params[:location_name])
    @stuff.location = @location
    logger.info "Stuff: #{@stuff.id}"
    logger.info "Location: #{@location.id}"
    logger.info "New location: #{@stuff.location.id}"
    logger.info "New location: #{@stuff.location.id}"
    result = @stuff.save!
    redirect_to params[:destination] || stuff_index_path, :notice => (result ? 'Logged' : 'Problem?') and return
  end
  # GET /stuff/1
  # GET /stuff/1.xml
  def show
    @stuff = Stuff.find(params[:id])
    @location_histories = @stuff.location_histories.order(:updated_at)
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @stuff }
    end
{'fraction_non_alphanumeric': 0.13794135248354278, 'fraction_numerical': 0.0011968880909634949, 'mean_word_length': 3.1631382316313825, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, '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': '3379855', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1083, 'n_words': 246}