<commit_before>class Admin::StopAreasController < Admin::AdminController
  
  def show 
    @stop_area = StopArea.find(params[:id])
  end
  
  def index
    conditions = []
    if !params[:query].blank? or !params[:mode].blank?
      conditions = StopArea.name_or_id_conditions(params[:query], params[:mode])
    end
    @stop_areas = StopArea.paginate :page => params[:page], 
                                    :conditions => conditions, 
                                    :order => 'name'
  end
  
  def new
    @stop_area = StopArea.new(:loaded => true)
  end
  
  def create 
    @stop_area = StopArea.new(params[:stop_area])
    if @stop_area.save
      flash[:notice] = t('admin.stop_area_created')
      redirect_to(admin_url(admin_stop_area_path(@stop_area.id)))
    else
      render :new
    end
  end
  
  def update
    @stop_area = StopArea.find(params[:id])
    if @stop_area.update_attributes(params[:stop_area])
      flash[:notice] = t('admin.stop_area_updated')
      redirect_to admin_url(admin_stop_area_path(@stop_area.id))
    else
      flash[:error] = t('admin.stop_area_problem')
      render :show
    end
  end
  
  def destroy
    @stop_area = StopArea.find(params[:id])
    if @stop_area.campaigns.size > 0
      flash[:error] = t('admin.stop_area_has_campaigns')<commit_msg>Add eager loading and sort for stop areas.<commit_after>class Admin::StopAreasController < Admin::AdminController
  
  def show 
    @stop_area = StopArea.find(params[:id])
  end
  
  def index
    conditions = []
    if !params[:query].blank? or !params[:mode].blank?
      conditions = StopArea.name_or_id_conditions(params[:query], params[:mode])
    end
    @stop_areas = StopArea.paginate :page => params[:page], 
                                    :conditions => conditions, 
                                    :include => :locality,
                                    :order => 'lower(name)'
  end
  
  def new
    @stop_area = StopArea.new(:loaded => true)
  end
  
  def create 
    @stop_area = StopArea.new(params[:stop_area])
    if @stop_area.save
      flash[:notice] = t('admin.stop_area_created')
      redirect_to(admin_url(admin_stop_area_path(@stop_area.id)))
    else
      render :new
    end
  end
  
  def update
    @stop_area = StopArea.find(params[:id])
    if @stop_area.update_attributes(params[:stop_area])
      flash[:notice] = t('admin.stop_area_updated')
      redirect_to admin_url(admin_stop_area_path(@stop_area.id))
    else
      flash[:error] = t('admin.stop_area_problem')
      render :show
    end
  end
  
  def destroy
    @stop_area = StopArea.find(params[:id])
    if @stop_area.campaigns.size > 0
      flash[:error] = t('admin.stop_area_has_campaigns')
{'fraction_non_alphanumeric': 0.11951309479896717, 'fraction_numerical': 0.0007377351530800443, 'mean_word_length': 2.6747967479674797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1076350', 'n_tokens_mistral': 881, 'n_tokens_neox': 859, 'n_words': 156}