<commit_before>class TrainingsController < ApplicationController
  skip_before_action :verify_authenticity_token, :export

  # GET /trainings
  # GET /trainings.json
  def index
    @trainings = Training.all

    if params[:id]
      @training = Training.find_by_id((params[:id]))
    else
      @training = Training.last
    end

    respond_to do |format|
      format.html
    end
  end

  def export
    begin
      if params[:training] != nil && params[:training][:location] != nil && params[:training][:datetime] != nil
        locations = params[:training][:location]

        if locations.count > 0
          training = Training.create!(:created_at => Time.at((params[:training][:datetime].to_i/1000)))

          locations.each do |xml_location|
            if xml_location["latitude"] != nil && xml_location["longitude"] != nil
              location = Location.new
              location.latitude = xml_location["latitude"]
              location.longitude = xml_location["longitude"]
              location.training_id = training.id
              location.save!
            end
          end
        end
      end
    rescue TimeoutError => e
      MyLog.debug "timeout #{e}"
    end

    render :nothing => true
  end

  # DELETE /trainings/1
  # DELETE /trainings/1.json
  def destroy
    @training = Training.find(params[:id])
    @training.destroy

    respond_to do |format|
      format.html { redirect_to trainings_url }
    end
  end

end<commit_msg>improved readability through replacing if != nil with unless nil?<commit_after>class TrainingsController < ApplicationController
  skip_before_action :verify_authenticity_token, :export

  # GET /trainings
  # GET /trainings.json
  def index
    @trainings = Training.all

    if params[:id]
      @training = Training.find_by_id((params[:id]))
    else
      @training = Training.last
    end

    respond_to do |format|
      format.html
    end
  end

  def export
    begin
      unless params[:training].nil? && params[:training][:location].nil? && params[:training][:datetime].nil?
        locations = params[:training][:location]

        if locations.count > 0
          training = Training.create!(:created_at => Time.at((params[:training][:datetime].to_i/1000)))

          locations.each do |xml_location|
            unless xml_location["latitude"].nil? && xml_location["longitude"].nil?
              location = Location.new
              location.latitude = xml_location["latitude"]
              location.longitude = xml_location["longitude"]
              location.training_id = training.id
              location.save!
            end
          end
        end
      end
    rescue TimeoutError => e
      MyLog.debug "timeout #{e}"
    end

    render :nothing => true
  end

  # DELETE /trainings/1
  # DELETE /trainings/1.json
  def destroy
    @training = Training.find(params[:id])
    @training.destroy

    respond_to do |format|
      format.html { redirect_to trainings_url }
    end
  end

end
{'fraction_non_alphanumeric': 0.10668896321070234, 'fraction_numerical': 0.0046822742474916385, 'mean_word_length': 2.4578034682080925, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '409295', 'n_tokens_mistral': 864, 'n_tokens_neox': 834, 'n_words': 194}