<commit_before>class Service
  attr_reader :name, :slug, :excluded_from_list

  def initialize(service_config)
    @name = service_config["name"]
    @slug = service_config["slug"]
    @excluded_from_list = service_config["excluded_from_list"] || false
    @toggle = service_config["feature_toggle"]
  end

  def toggled_on?
    @toggle.nil? ? true : Rails.application.config.feature_toggles[@toggle.to_sym]
  end
end

services_yaml_path = Rails.root.join("config", "services.yml")

dashboards = YAML.load(File.read(services_yaml_path))["dashboards"]

services = dashboards.map {|properties| Service.new(properties)}.select(&:toggled_on?).map {|service| [service.slug, service] }

Limelight::Application.config.available_services = Hash[*services.flatten]<commit_msg>Simplify service parsing by using index_by.<commit_after>class Service
  attr_reader :name, :slug, :excluded_from_list

  def initialize(service_config)
    @name = service_config["name"]
    @slug = service_config["slug"]
    @excluded_from_list = service_config["excluded_from_list"] || false
    @toggle = service_config["feature_toggle"]
  end

  def toggled_on?
    @toggle.nil? ? true : Rails.application.config.feature_toggles[@toggle.to_sym]
  end
end

services_yaml_path = Rails.root.join("config", "services.yml")

dashboards = YAML.load(File.read(services_yaml_path))["dashboards"]

services = dashboards.map {|properties| Service.new(properties)}.select(&:toggled_on?)

Limelight::Application.config.available_services = services.index_by(&:slug)
{'fraction_non_alphanumeric': 0.1318032786885246, 'fraction_numerical': 0.0, 'mean_word_length': 6.301435406698564, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4602502', 'n_tokens_mistral': 505, 'n_tokens_neox': 497, 'n_words': 79}