<commit_before>module Amr
  class LowCarbonHubDownloadAndUpsert
    def initialize(
        low_carbon_hub_installation:,
        start_date:,
        end_date:,
        low_carbon_hub_api: LowCarbonHubMeterReadings.new
      )
      @low_carbon_hub_installation = low_carbon_hub_installation
      @low_carbon_hub_api = low_carbon_hub_api
      @start_date = start_date
      @end_date = end_date
    end

    def perform
      readings = LowCarbonHubDownloader.new(low_carbon_hub_installation: @low_carbon_hub_installation, start_date: @start_date, end_date: @end_date, low_carbon_hub_api: @low_carbon_hub_api).readings
      LowCarbonHubUpserter.new(low_carbon_hub_installation: @low_carbon_hub_installation, readings: readings).perform
    end
  end
end<commit_msg>Create with username/password<commit_after>module Amr
  class LowCarbonHubDownloadAndUpsert
    def initialize(
        low_carbon_hub_installation:,
        start_date:,
        end_date:
      )
      @low_carbon_hub_installation = low_carbon_hub_installation
      @start_date = start_date
      @end_date = end_date
    end

    def perform
      readings = LowCarbonHubDownloader.new(low_carbon_hub_installation: @low_carbon_hub_installation, start_date: @start_date, end_date: @end_date, low_carbon_hub_api: low_carbon_hub_api).readings
      LowCarbonHubUpserter.new(low_carbon_hub_installation: @low_carbon_hub_installation, readings: readings).perform
    end

    private

    def low_carbon_hub_api
      @low_carbon_hub_api ||= LowCarbonHubMeterReadings.new(username: username, password: password)
    end

    def username
      @low_carbon_hub_installation.username || ENV['ENERGYSPARKSRBEEUSERNAME']
    end

    def password
      @low_carbon_hub_installation.password || ENV['<PASSWORD>']
    end
  end
end
{'fraction_non_alphanumeric': 0.06305803571428571, 'fraction_numerical': 0.0, 'mean_word_length': 4.197101449275363, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3430905', 'n_tokens_mistral': 622, 'n_tokens_neox': 588, 'n_words': 92}