<commit_before>class SettlementsController < ApplicationController
  # GET /settlements
  # GET /settlements.json
  def index
    @settlements = Settlement.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @settlements }
    end
  end

  # GET /settlements/1
  # GET /settlements/1.json
  def show
    @settlement = Settlement.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @settlement }
    end
  end

  # GET /settlements/new
  # GET /settlements/new.json
  def new
    @settlement = Settlement.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @settlement }
    end
  end

  # GET /settlements/1/edit
  def edit
    @settlement = Settlement.find(params[:id])
  end

  # POST /settlements
  # POST /settlements.json
  def create
    @settlement = Settlement.new(params[:settlement])

    respond_to do |format|
      if @settlement.save
        format.html { redirect_to @settlement, notice: 'Settlement was successfully created.' }
        format.json { render json: @settlement, status: :created, location: @settlement }
      else
        format.html { render action: "new" }
        format.json { render json: @settlement.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /settlements/1
  # PUT /settlements/1.json
  def update
    @settlement = Settlement.find(params[:id])

    respond_to do |format|
      if @settlement.update_attributes(params[:settlement])
        format.html { redirect_to @settlement, notice: 'Settlement was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @settlement.errors, status: :unprocessable_entity }
      end<commit_msg>adding initial beings to the settlement on create<commit_after>class SettlementsController < ApplicationController
  # GET /settlements
  # GET /settlements.json
  def index
    @settlements = Settlement.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @settlements }
    end
  end

  # GET /settlements/1
  # GET /settlements/1.json
  def show
    @settlement = Settlement.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @settlement }
    end
  end

  # GET /settlements/new
  # GET /settlements/new.json
  def new
    @settlement = Settlement.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @settlement }
    end
  end

  # GET /settlements/1/edit
  def edit
    @settlement = Settlement.find(params[:id])
  end

  # POST /settlements
  # POST /settlements.json
  def create
    @settlement = Settlement.new(params[:settlement])
    @settlement.save
    params[:settlement][:population].to_i.times do
      @settlement.beings << Person.create
    end       
    params[:settlement][:population].to_i.times do
      @settlement.beings << Person.create
    end   
    @settlement.beings.each do |b| 
      b.settlement = @settlement 
      b.save
    end
    respond_to do |format|
      if @settlement.save
        format.html { redirect_to @settlement, notice: 'Settlement was successfully created.' }
        format.json { render json: @settlement, status: :created, location: @settlement }
      else
        format.html { render action: "new" }
        format.json { render json: @settlement.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /settlements/1
  # PUT /settlements/1.json
  def update
    @settlement = Settlement.find(params[:id])

    respond_to do |format|
      if @settlement.update_attributes(params[:settlement])
        format.html { redirect_to @settlement, notice: 'Settlement was successfully updated.' }
        format.json { head :ok }
      else
        format.html { render action: "edit" }
        format.json { render json: @settlement.errors, status: :unprocessable_entity }
      end
{'fraction_non_alphanumeric': 0.10076373491007637, 'fraction_numerical': 0.002463661000246366, 'mean_word_length': 2.7145471180237877, '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': '5438261', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1226, 'n_words': 316}