<commit_before>class SubscriptionsController < ApplicationController
	include EntriesHelper

	helpers()

	def index
		@subscriptions = current_user.subscriptions
		if @filters[:unseen]
			@subscriptions = @subscriptions.changed_for(current_user)
		end
		if @filters[:starred]
			@subscriptions = @subscriptions.with_stars
		end
	end

	def show
		@subscription = current_user.subscriptions.find(params[:id])
		@parent = @subscription
		entries_context
	end

	def create
		url = params.require(:subscription).permit(:feed_url)
		feed = Feed.find_or_create_by!(url)
		subscription = Subscription.find_or_create_by(user: current_user, feed: feed)
		flash[:success] = "Subscribed to feed #{feed.title}"
		redirect_303 subscription
	rescue ActiveRecord::RecordInvalid
		flash[:error] =  "Not a valid feed: #{url[:feed_url]}"
		redirect_back_or_rescue
	end

	def destroy
		subscription = current_user.subscriptions.find(params[:id])
		subscription.destroy
		redirect_back_or_rescue
	end

end<commit_msg>changed find_or_create to (rails4) first_or_create<commit_after>class SubscriptionsController < ApplicationController
	include EntriesHelper

	helpers()

	def index
		@subscriptions = current_user.subscriptions
		if @filters[:unseen]
			@subscriptions = @subscriptions.changed_for(current_user)
		end
		if @filters[:starred]
			@subscriptions = @subscriptions.with_stars
		end
	end

	def show
		@subscription = current_user.subscriptions.find(params[:id])
		@parent = @subscription
		entries_context
	end

	def create
		url = params.require(:subscription).permit(:feed_url)
		feed = Feed.where(url).first_or_create!
		subscription = Subscription.where(user: current_user, feed: feed).first_or_create
		flash[:success] = "Subscribed to feed #{feed.title}"
		redirect_303 subscription
	rescue ActiveRecord::RecordInvalid
		flash[:error] =  "Not a valid feed: #{url[:feed_url]}"
		redirect_back_or_rescue
	end

	def destroy
		subscription = current_user.subscriptions.find(params[:id])
		subscription.destroy
		redirect_back_or_rescue
	end

end
{'fraction_non_alphanumeric': 0.09425625920471281, 'fraction_numerical': 0.003436426116838488, 'mean_word_length': 5.6819672131147545, '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': '3422777', 'n_tokens_mistral': 692, 'n_tokens_neox': 642, 'n_words': 133}