<commit_before>class RequestsController < ApplicationController
  def create
    @request = Request.new(job_id: params[:job_id], client_id: current_user.id)
    job = Job.find(params[:job_id])
    if @request.save
      Notification.create(
        user_id: job.contractor.id, 
        sender_id: current_user.id, 
        request_id: @request.id,
        job_id: params[:job_id], 
        kind: "offer"
      )
      
      # UserMailer.request_made_email(job.contractor).deliver_now
      redirect_to '/jobs', notice: "Offer Made for '#{job.title}'!"
    end
  end

  def update
    request = Request.find(params[:id])
    request.accepted = params[:accepted]
    if request.save
      notification = Notification.new(
        user_id: request.client.id, sender_id: current_user.id, request_id: request.id
      )
      notification.kind = params[:accepted] ? "accepted" : "declined"
      notification.save
    end
    redirect_to request.headers["HTTP_REFERER"]
  end
end<commit_msg>Add request to notification when request is created<commit_after>class RequestsController < ApplicationController
  def create
    @request = Request.new(job_id: params[:job_id], client_id: current_user.id)
    job = Job.find(params[:job_id])
    if @request.save
      Notification.create(
        user_id: job.contractor.id, 
        sender_id: current_user.id, 
        request_id: @request.id,
        job_id: params[:job_id], 
        kind: "offer"
      )
      
      # UserMailer.request_made_email(job.contractor).deliver_now
      redirect_to '/jobs', notice: "Offer Made for '#{job.title}'!"
    end
  end

  def update
    @request = Request.find(params[:id])
    @request.accepted = params[:accepted]
    if @request.save
      notification = Notification.new(
        user_id: @request.client.id, sender_id: current_user.id, request_id: @request.id
      )
      notification.kind = params[:accepted] ? "accepted" : "declined"
      notification.save
    end
    redirect_to @request.headers["HTTP_REFERER"]
  end
end
{'fraction_non_alphanumeric': 0.11199207135777998, 'fraction_numerical': 0.0, 'mean_word_length': 3.005952380952381, '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': '4876741', 'n_tokens_mistral': 646, 'n_tokens_neox': 629, 'n_words': 128}