<commit_before>class UsersController < ApplicationController

	def index
		render json: User.all
	end

	def create
		user = User.new(user_params)

		skill_params.each do |skill, value|
			if value == true
				current_skill = Skill.find_or_create_by(name: skill)
				user.skills << current_skill 
				current_skill.increase_frequency
			end
		end

		if user.save
			render json: {user: user.id, token: create_token(user)}
			session[:user_id] = user.id
		else
			session[:errors] = "invalid user data"
		end
	end

	def update
		user = User.find(params[:id])

		user.update_attributes(user_params)

		skill_params.each do |skill, value|
			if value == true and !user.skills.include?(skill)
				current_skill = Skill.find_or_create_by(name: skill)
				user.skills << current_skill
				current_skill.increase_frequency
			elsif value == false and user.skills.include?(skill)
				user.skills.delete(skill)
				current_skill.decrease_frequency
			end
		end
	end

	def show
		user = User.find(params[:id])
		render json: user
	end
<commit_msg>fixes update action bug in user controller<commit_after>class UsersController < ApplicationController

	def index
		render json: User.all
	end

	def create
		user = User.new(user_params)

		skill_params.each do |skill, value|
			if value == true
				current_skill = Skill.find_or_create_by(name: skill)
				user.skills << current_skill 
				current_skill.increase_frequency
			end
		end

		if user.save
			render json: {user: user.id, token: create_token(user)}
			session[:user_id] = user.id
		else
			session[:errors] = "invalid user data"
		end
	end

	def update
		user = User.find(params[:id])

		user.update_attributes(user_params)

		skill_params.each do |skill, value|
			current_skill = Skill.find_or_create_by(name: skill)
			if value == true and !user.skills.include?(current_skill)
				user.skills << current_skill
				current_skill.increase_frequency
			elsif value == false and user.skills.include?(current_skill)
				user.skills.delete(current_skill)
				current_skill.decrease_frequency
			end
		end
	end

	def show
		user = User.find(params[:id])
		render json: user
	end

{'fraction_non_alphanumeric': 0.09133709981167608, 'fraction_numerical': 0.0, 'mean_word_length': 3.8076923076923075, 'pattern_counts': {'":': 0, '<': 13, '<?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': '5617677', 'n_tokens_mistral': 827, 'n_tokens_neox': 731, 'n_words': 172}