<commit_before>class TopicsController < ApplicationController
  load_and_authorize_resource only: [:new, :edit, :create, :update, :destroy, :favorite, :unfavorite, :follow, :unfollow, :suggest, :unsuggest]

  def index
  end

  def feed
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(topic_params)
    @topic.user_id = current_user.id
    @topic.node_id = params[:node] || topic_params[:node_id]
    if @topic.save
      redirect_to(topic_path(@topic.id), notice: "Topic created successfully.")
    else
      render action: :new
    end
  end

  def edit
  end

  def update
  end

  def destroy
  end

  def preview
  end

  def recent
  end

  def excellent
    @topics = Topic.excellent.recent.includes(:user)
    @topics = @topics.paginate(page: params[:page], per_page: 20)
    render action: :index
  end

  %W(no_reply popular).each do |name|
	  define_method(name) do
	  end
  end

  def node
    @node = Node.find(params[:id])
    @topics = @node.topics.last_activated.includes(:user).paginate(page: params[:page], per_page: 20)
    render action: :index
  end

  def follow
  end

  def unfollow
  end

  def favorite
	  current_user.favorite_topic(params[:id])
	  render text: '1'
  end

  def unfavorite
	  current_user.unfavorite_topic(params[:id])
	  render text: '1'<commit_msg>Add the methods to allow user to follow or unfollow an specified topic.<commit_after>class TopicsController < ApplicationController
  load_and_authorize_resource only: [:new, :edit, :create, :update, :destroy, :favorite, :unfavorite, :follow, :unfollow, :suggest, :unsuggest]

  def index
  end

  def feed
  end

  def new
    @topic = Topic.new
  end

  def create
    @topic = Topic.new(topic_params)
    @topic.user_id = current_user.id
    @topic.node_id = params[:node] || topic_params[:node_id]
    if @topic.save
      redirect_to(topic_path(@topic.id), notice: "Topic created successfully.")
    else
      render action: :new
    end
  end

  def edit
  end

  def update
  end

  def destroy
  end

  def preview
  end

  def recent
  end

  def excellent
    @topics = Topic.excellent.recent.includes(:user)
    @topics = @topics.paginate(page: params[:page], per_page: 20)
    render action: :index
  end

  %W(no_reply popular).each do |name|
	  define_method(name) do
	  end
  end

  def node
    @node = Node.find(params[:id])
    @topics = @node.topics.last_activated.includes(:user).paginate(page: params[:page], per_page: 20)
    render action: :index
  end

  def follow
    @topic = Topic.find(params[:id])
    @topic.push_follower(current_user.id)
    render text: '1'
  end

  def unfollow
    @topic = Topic.find(params[:id])
    @topic.pull_follower(current_user.id)
    render text: '1'
  end

  def favorite
	  current_user.favorite_topic(params[:id])
	  render text: '1'
  end

  def unfavorite
	  current_user.unfavorite_topic(params[:id])
	  render text: '1'
{'fraction_non_alphanumeric': 0.10863605209047293, 'fraction_numerical': 0.004797806716929404, 'mean_word_length': 3.330860534124629, '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': '5268961', 'n_tokens_mistral': 1056, 'n_tokens_neox': 993, 'n_words': 257}