<commit_before>class Metrics::AccessibilityController < ApplicationController

  def details
    @repositories = Repository.all
    if params[:repository]
      @repository = Repository.find params[:repository]
    else
      @repository = @repositories.first
    end
  end

end<commit_msg>Group accessibility results per source portal<commit_after>class Metrics::AccessibilityController < ApplicationController

  def details
    @repositories = Repository.all
    if params[:repository]
      @repository = Repository.find params[:repository]
    else
      @repository = @repositories.first
    end

    if @repository.id == 'GovData.de'
      gon.portals = group_by_portal
    end
  end

  def group_by_portal
    field = 'extras.metadata_original_portal'
    grouped = Hash.new { |h, k| h[k] = [] }
    for record in @repository.metadata_with_field(field)
      grouped[record[:extras][:metadata_original_portal]] << record[:accessibility]
    end
    grouped.each { |portal, scores| grouped[portal] = scores.inject(:+)/scores.length }
  end

end
{'fraction_non_alphanumeric': 0.09705042816365367, 'fraction_numerical': 0.0, 'mean_word_length': 3.8256880733944953, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2269058', 'n_tokens_mistral': 311, 'n_tokens_neox': 304, 'n_words': 68}