<commit_before>module AnswersHelper

  def user_can_vote_answer? current_user, answer
    return false unless current_user
    user_vote = Vote.find_by(user_id: current_user.id, answer_id: answer.id)
    user_vote.nil?
  end

  def user_can_vote answer
    user_vote = Vote.find_by(user_id: current_user.id, answer_id: answer.id)
    if user_vote.nil?
      content_tag(:div, class:"large-1 columns", id:"answer#{answer.id}-vote-controls") do
        concat link_to("<i class='fa fa-chevron-up'></i>".html_safe, vote_up_answer_path(answer), remote: true)
        concat "<h3><div id='votes-for-answer-#{answer.id}' >#{answer.votes_value}</div></h3><br />".html_safe
        concat link_to("<i class='fa fa-chevron-down'></i>".html_safe, vote_down_answer_path(answer), remote: true)
      end
    else
      content_tag(:div, class:"large-1 columns", id:"answer#{answer.id}-vote-controls") do
        concat "<i class='fa fa-chevron-up'></i>".html_safe
        concat "<h3><div id='votes-for-answer-#{answer.id}' >#{answer.votes_value}</div></h3><br />".html_safe
        concat "<i class='fa fa-chevron-down'></i>".html_safe
      end
    end
  end
end<commit_msg>Refactor answer helper<commit_after>module AnswersHelper

  def user_can_vote_answer? current_user, answer
    return false unless current_user
    user_vote = Vote.find_by(user_id: current_user.id, answer_id: answer.id)
    user_vote.nil?
  end

  def user_can_vote answer
    user_vote = Vote.find_by(user_id: current_user.id, answer_id: answer.id)

    html = content_tag(:div, class:"large-1 columns", id:"answer#{answer.id}-vote-controls") do
        concat "<i class='fa fa-chevron-up'></i>".html_safe
        concat "<h3><div id='votes-for-answer-#{answer.id}' >#{answer.votes_value}</div></h3><br />".html_safe
        concat "<i class='fa fa-chevron-down'></i>".html_safe
      end
    if user_vote.nil?
      html = content_tag(:div, class:"large-1 columns", id:"answer#{answer.id}-vote-controls") do
          concat link_to("<i class='fa fa-chevron-up'></i>".html_safe, vote_up_answer_path(answer), remote: true)
          concat "<h3><div id='votes-for-answer-#{answer.id}' >#{answer.votes_value}</div></h3><br />".html_safe
          concat link_to("<i class='fa fa-chevron-down'></i>".html_safe, vote_down_answer_path(answer), remote: true)
        end
    end

    return html
  end
end
{'fraction_non_alphanumeric': 0.16060862214708369, 'fraction_numerical': 0.00507185122569738, 'mean_word_length': 3.8504098360655736, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '7293566', 'n_tokens_mistral': 845, 'n_tokens_neox': 832, 'n_words': 154}