<commit_before>class CmmCallbacksController < ApplicationController
  skip_before_filter :verify_authenticity_token, only: [:create]

  before_action :set_callback, only: [:show]

  # GET /callbacks
  # GET /callbacks.json
  def index
    @callbacks = CmmCallback.all
  end

  # GET /callbacks/1
  # GET /callbacks/1.json
  def show
    respond_to do |format|
      format.html { render :show }
      format.json { render json: @callback }
    end
  end

  # POST /callbacks.json {JSON body}
  # this is the method that is called directly by CoverMyMeds when a PA is created
  # retrospectively by a pharmacist. This method needs to create a new PA record in
  # the demo system, and respond appropriately, if it can match the PA to a prescription
  # that we created previously.

  # this method is also called whenever the status or a value of a property in the PA
  # changes. In that case, we need to update the PA record in our system with the
  # new values in the callback.
  def create
    # pull the pa request out of the JSON
    @request = request_params

    # create a callback object to log that we received this callback
    @callback = CmmCallback.new content: @request.to_json

    # see if the PA exists already in our local database
    @pa = PaRequest.find_by_cmm_id(@request['id'])

    if @pa.nil?
      # couldn't find it in our db, must be a retrospective
      @pa = PaRequest.new
      @pa.init_from_callback(@request)
    else
      # if we have a record of the PA, delete it if appropriate
      if is_delete?(@request)
        @pa.update_attributes(cmm_token: nil)
      else
        # if it's not a delete, then it's an update
        @pa.update_from_callback(@request)
      end
    end

    # save our updated PA, and keep track of the callback that spawned it
    @pa.save
    @callback.pa_request = @pa
    @pa.cmm_callbacks << @callback
    @callback.save!
    @pa_request = @pa

    # send our response back to CMM
    respond_to do |format|
      if @pa.save
        format.html { render 'pa_requests/show'}
        format.json { render json: @pa }
      else
        format.html { render :error }
        format.json { render json: @callback }
      end
    end
  end<commit_msg>lets just render a 200 with nothing<commit_after>class CmmCallbacksController < ApplicationController
  skip_before_filter :verify_authenticity_token, only: [:create]

  before_action :set_callback, only: [:show]

  # GET /callbacks
  # GET /callbacks.json
  def index
    @callbacks = CmmCallback.all
  end

  # GET /callbacks/1
  # GET /callbacks/1.json
  def show
    respond_to do |format|
      format.html { render :show }
      format.json { render json: @callback }
    end
  end

  # POST /callbacks.json {JSON body}
  # this is the method that is called directly by CoverMyMeds when a PA is created
  # retrospectively by a pharmacist. This method needs to create a new PA record in
  # the demo system, and respond appropriately, if it can match the PA to a prescription
  # that we created previously.

  # this method is also called whenever the status or a value of a property in the PA
  # changes. In that case, we need to update the PA record in our system with the
  # new values in the callback.
  def create
    # pull the pa request out of the JSON
    @request = request_params

    # create a callback object to log that we received this callback
    @callback = CmmCallback.new content: @request.to_json

    # see if the PA exists already in our local database
    @pa = PaRequest.find_by_cmm_id(@request['id'])

    if @pa.nil?
      # couldn't find it in our db, must be a retrospective
      @pa = PaRequest.new
      @pa.init_from_callback(@request)
    else
      # if we have a record of the PA, delete it if appropriate
      if is_delete?(@request)
        @pa.update_attributes(cmm_token: nil)
      else
        # if it's not a delete, then it's an update
        @pa.update_from_callback(@request)
      end
    end

    # save our updated PA, and keep track of the callback that spawned it
    @pa.save
    @callback.pa_request = @pa
    @pa.cmm_callbacks << @callback
    @callback.save!

    # send our response back to CMM
    respond_to do |format|
      if @pa.save
        format.html { render status: 200, nothing: true }
        format.json { render json: @pa }
      else
        format.html { render :error }
        format.json { render json: @callback }
      end
    end
  end
{'fraction_non_alphanumeric': 0.07134818816115238, 'fraction_numerical': 0.0022507314877335135, 'mean_word_length': 2.706422018348624, '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': '1204087', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1290, 'n_words': 530}