<commit_before>class ProjectsController < ApplicationController
  include ServiceRoles

  before_action :set_project, only: [
    :bootstrap,
    :check_interfaces,
    :check_problem_identifiers,
    :destroy,
    :edit,
    :merge,
    :show,
    :update,
    :update_service
  ]
  before_action :set_roles # defined in 'concerns/service_roles.rb'
  before_action :set_available_services, only: [
    :create,
    :edit,
    :new,
    :show
  ]
  before_action :set_interfaces, only: [
    :create,
    :edit,
    :new
  ]

  # GET /projects
  def index
    objects_per_page = Rails.configuration.x.dalphi['paginated-objects-per-page']['projects']
    @projects = Project.where(user: current_user)
                       .paginate(
                         page: params[:page],
                         per_page: objects_per_page
                       )
  end

  # GET /projects/1
  def show
  end

  # GET /projects/new
  def new
    @project = Project.new
  end

  # GET /projects/1/edit
  def edit
  end

  # POST /projects
  def create
    @project = Project.new(params_with_associated_models)
    @project.user = current_user
    @project.connect_services
    if @project.save
      redirect_to project_raw_data_path(@project), notice: I18n.t('projects.action.create.success')
    else
      flash[:error] = I18n.t('simple_form.error_notification.default_message')
      render :new
    end
  end

  # PATCH/PUT /projects/1
  def update
    if @project.update(params_with_associated_models)<commit_msg>auto select services for new projects<commit_after>class ProjectsController < ApplicationController
  include ServiceRoles

  before_action :set_project, only: [
    :bootstrap,
    :check_interfaces,
    :check_problem_identifiers,
    :destroy,
    :edit,
    :merge,
    :show,
    :update,
    :update_service
  ]
  before_action :set_roles # defined in 'concerns/service_roles.rb'
  before_action :set_available_services, only: [
    :create,
    :edit,
    :new,
    :show
  ]
  before_action :set_interfaces, only: [
    :create,
    :edit,
    :new
  ]

  # GET /projects
  def index
    objects_per_page = Rails.configuration.x.dalphi['paginated-objects-per-page']['projects']
    @projects = Project.where(user: current_user)
                       .paginate(
                         page: params[:page],
                         per_page: objects_per_page
                       )
  end

  # GET /projects/1
  def show
  end

  # GET /projects/new
  def new
    @project = Project.new
    @project.connect_services
  end

  # GET /projects/1/edit
  def edit
  end

  # POST /projects
  def create
    @project = Project.new(params_with_associated_models)
    @project.user = current_user
    @project.connect_services
    if @project.save
      redirect_to project_raw_data_path(@project), notice: I18n.t('projects.action.create.success')
    else
      flash[:error] = I18n.t('simple_form.error_notification.default_message')
      render :new
    end
  end

  # PATCH/PUT /projects/1
  def update
    if @project.update(params_with_associated_models)
{'fraction_non_alphanumeric': 0.09564085881587508, 'fraction_numerical': 0.004554326610279766, 'mean_word_length': 2.5672853828306264, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5271020', 'n_tokens_mistral': 1002, 'n_tokens_neox': 962, 'n_words': 195}