<commit_before>class EvidenceController < FactsController

  before_filter :authenticate_user!, :except => [:index]

  respond_to :json

  def index
    @fact = Fact[params[:fact_id]] || raise_404("Fact not found")
    @evidence = @fact.evidence(relation)

    authorize! :get_evidence, @fact

    @fact_relations = @evidence
    render 'fact_relations/index'
  end

  class EvidenceNotFoundException < StandardError
  end<commit_msg>Sorts the fact relations. This should really, really be moved to a query. Then we also have to build queries to add opinions and authority, just as with comments, and I felt I was a bit in over my head with that. Perhaps look at this a bit more tomorrow, or do we choose to get technical debt?<commit_after>class EvidenceController < FactsController

  before_filter :authenticate_user!, :except => [:index]

  respond_to :json

  def index
    @fact = Fact[params[:fact_id]] || raise_404("Fact not found")
    @evidence = @fact.evidence(relation)

    authorize! :get_evidence, @fact

    @fact_relations = @evidence.to_a.sort do |a,b|
      opinionA = a.get_user_opinion
      opinionB = b.get_user_opinion
      (opinionB.beliefs - opinionB.disbeliefs) <=> (opinionA.beliefs - opinionA.disbeliefs)
    end

    render 'fact_relations/index'
  end

  class EvidenceNotFoundException < StandardError
  end
{'fraction_non_alphanumeric': 0.0880597014925373, 'fraction_numerical': 0.004477611940298508, 'mean_word_length': 4.1183206106870225, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '813705', 'n_tokens_mistral': 433, 'n_tokens_neox': 383, 'n_words': 127}