<commit_before>class QuestionsController < ApplicationController
  def index
    @question = Question.all
  end

  def show
    @question = Question.find(params[:id])
    @answers = @question.answers.all
    @comment = Comment.new
    @answer = Answer.new
    @answers = @question.answers.all.order("created_at DESC")
    @question_comments = @question.comments.all.order("created_at DESC")
    @vote = Vote.new #add for votes
    @vote_count = @question.votes.pluck(:value).reduce(:+) || 0

  end

  def new
    require_logged_in
    @question = Question.new
  end

  def create
    require_logged_in
    @question = Question.new(question_params)
    if @question.save
      redirect_to @question
    else
      flash[:alert] = @question.errors.full_messages
      redirect_to root_path
    end
  end

  def edit
    @question = Question.find(params[:id])<commit_msg>added view count for question<commit_after>class QuestionsController < ApplicationController
  def index
    @question = Question.all
  end

  def show
    @question = Question.find(params[:id])
    @answers = @question.answers.all
    @comment = Comment.new
    @answer = Answer.new
    @answers = @question.answers.all.order("created_at DESC")
    @question_comments = @question.comments.all.order("created_at DESC")
    @question.increment!(:view_count)
    @vote = Vote.new #add for votes
    @vote_count = @question.votes.pluck(:value).reduce(:+) || 0
  end

  def new
    require_logged_in
    @question = Question.new
  end

  def create
    require_logged_in
    @question = Question.new(question_params)
    if @question.save
      redirect_to @question
    else
      flash[:alert] = @question.errors.full_messages
      redirect_to root_path
    end
  end

  def edit
    @question = Question.find(params[:id])
{'fraction_non_alphanumeric': 0.10508664058133035, 'fraction_numerical': 0.0011179429849077697, 'mean_word_length': 3.2822966507177034, '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': '5756685', 'n_tokens_mistral': 577, 'n_tokens_neox': 553, 'n_words': 122}