<commit_before>module Stattleship
  class Endpoint < OpenStruct
    def self.fetch(path:, params:)
      Stattleship::Client.new(path: path,
                              query: params.query).
        paginate(model: self)
    end

    def data
      @data ||= populate
    end

    def populate
      raise 'Endpoint subclass must implement populate'
    end

    private

    def populate_officials(model)
      model.officials = []

      return if model.official_ids.nil?
      return if model.officials.nil?

      model.official_ids.each do |official_id|
        model.officials << officials.detect do |official|
          official.id == official_id
        end
      end
    end

    def populate_opponents(model)<commit_msg>Handle cause when there are no officals on a game<commit_after>module Stattleship
  class Endpoint < OpenStruct
    def self.fetch(path:, params:)
      Stattleship::Client.new(path: path,
                              query: params.query).
        paginate(model: self)
    end

    def data
      @data ||= populate
    end

    def populate
      raise 'Endpoint subclass must implement populate'
    end

    private

    def populate_officials(model)
      model.officials = []

      return if model.official_ids.nil?
      return if officials.nil?

      model.official_ids.each do |official_id|
        model.officials << officials.detect do |official|
          official.id == official_id
        end
      end
    end

    def populate_opponents(model)
{'fraction_non_alphanumeric': 0.07429718875502007, 'fraction_numerical': 0.0, 'mean_word_length': 2.1473684210526316, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6583659', 'n_tokens_mistral': 453, 'n_tokens_neox': 408, 'n_words': 114}