<commit_before>class ProjectsController < ApplicationController
  before_action :set_project, only: [:show, :edit, :update, :destroy]
  before_action :authenticate_user!

  # GET /projects
  # GET /projects.json
  def index
    authorize Project
    @projects = Project.all
  end

  # GET /projects/1
  # GET /projects/1.json
  def show

  end

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

  # GET /projects/1/edit
  def edit
     authorize Project
  end

  # POST /projects
  # POST /projects.json
  def create
     authorize Project
     
    @project = Project.new(project_params)
    @project.created_by = current_user.id
    respond_to do |format|
      if @project.save
        format.html { redirect_to projects_path, notice: 'Project was successfully created.' }
        format.json { render :show, status: :created, location: @project }
      else
        format.html { render :new }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /projects/1
  # PATCH/PUT /projects/1.json
  def update
    authorize Project
    respond_to do |format|
      @project.modified_by = current_user.id
      if @project.update(project_params)
        format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }<commit_msg>completed project and transactions update. CATS-1638<commit_after>class ProjectsController < ApplicationController
  before_action :set_project, only: [:show, :edit, :update, :destroy]
  before_action :authenticate_user!

  # GET /projects
  # GET /projects.json
  def index
    authorize Project
    @projects = Project.all
  end

  # GET /projects/1
  # GET /projects/1.json
  def show

  end

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

  # GET /projects/1/edit
  def edit
     authorize Project
  end

  # POST /projects
  # POST /projects.json
  def create
     authorize Project
     
    @project = Project.new(project_params)
    @project.created_by = current_user.id
    respond_to do |format|
      if @project.save
        format.html { redirect_to projects_path, notice: 'Project was successfully created.' }
        format.json { render :show, status: :created, location: @project }
      else
        format.html { render :new }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /projects/1
  # PATCH/PUT /projects/1.json
  def update
    authorize Project
    respond_to do |format|
      @project.modified_by = current_user.id
      puts "------------------------------new #{project_params[:amount].to_d}--------#{@project.amount}"
      if project_params[:amount].to_d < @project.amount
        @project.errors[:amount] << 'can not be less than the previous amount.'
       
        format.html { render :edit }
        format.json { render json: @project.errors, status: :unprocessable_entity }
      
      
      elsif @project.valid? && @project.update(project_params)
        format.html { redirect_to projects_path, notice: 'Project was successfully updated.' }
{'fraction_non_alphanumeric': 0.10351377018043685, 'fraction_numerical': 0.004431782209559987, 'mean_word_length': 2.6574074074074074, 'pattern_counts': {'":': 0, '<': 8, '<?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': '3417167', 'n_tokens_mistral': 951, 'n_tokens_neox': 926, 'n_words': 258}