<commit_before>class ArtworksController < ApplicationController

  skip_before_action  :verify_authenticity_token

  def index
    @artworks = Artwork.all
    render json: @artworks
  end

  def new
    @artwork = Artwork.new
  end

  def create
    @artwork = Artwork.new(artwork_params)
    @artwork.artist = Artist.find_or_create_by(name: params["artist_name"])
    @artwork.movement_ids = params["movements"]

    if params["movement"] && params["movement"] != ""
      @artwork.movements << Movement.find_or_create_by(name: params["movement"].capitalize)
    end
    @artwork.save
  end

  def show
    respond_to do |f|
      @artwork = Artwork.find(params[:id])
      f.json { render json: @artwork}
    end
  end

  def update
    @artwork = Artwork.find(params[:id])
    @artwork.update(artwork_params)
    @artwork.save
  end

  def destroy
    @artwork = Artwork.find(params[:id])
    @artwork.destroy
  end

  private

  def artwork_params
    params.permit(:id, :title, :date_seen, :medium, :location)
  end

end
<commit_msg>update artist and movements in artwork update controller<commit_after>class ArtworksController < ApplicationController

  skip_before_action  :verify_authenticity_token

  def index
    @artworks = Artwork.all
    render json: @artworks
  end

  def new
    @artwork = Artwork.new
  end

  def create
    @artwork = Artwork.new(artwork_params)
    @artwork.artist = Artist.find_or_create_by(name: params["artist_name"])
    @artwork.movement_ids = params["movements"]

    if params["movement"] && params["movement"] != ""
      @artwork.movements << Movement.find_or_create_by(name: params["movement"].capitalize)
    end
    @artwork.save
  end

  def show
    respond_to do |f|
      @artwork = Artwork.find(params[:id])
      f.json { render json: @artwork}
    end
  end

  def update
    @artwork = Artwork.find(params[:id])
    @artwork.update(artwork_params)
    @artwork.artist = Artist.find_or_create_by(name: params["artist_name"])
    @artwork.movement_ids = params["movements"]
    if params["movement"] && params["movement"] != ""
      @artwork.movements << Movement.find_or_create_by(name: params["movement"].capitalize)
    end
    
    @artwork.save
  end

  def destroy
    @artwork = Artwork.find(params[:id])
    @artwork.destroy
  end

  private

  def artwork_params
    params.permit(:id, :title, :date_seen, :medium, :location)
  end

end

{'fraction_non_alphanumeric': 0.11532056619483763, 'fraction_numerical': 0.0, 'mean_word_length': 3.55977229601518, 'pattern_counts': {'":': 0, '<': 11, '<?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': '1351813', 'n_tokens_mistral': 829, 'n_tokens_neox': 803, 'n_words': 163}