<commit_before>require 'open-uri'
require 'json'

totalValue = 0

pipedriveApiUrl = 'https://api.pipedrive.com/v1/deals?filter_id=2&api_token=' + ENV['PIPEDRIVE_API_KEY']

SCHEDULER.every '24h', :first_in => 0 do |job|
  open pipedriveApiUrl do |f|
    result = JSON.parse(f.read)
    result['data'].each do |child|
      totalValue += child['value']
    end
    send_event('pipedrive-total-deal-value', {current: totalValue})
  end
end<commit_msg>Work without pipedrive api key<commit_after>require 'open-uri'
require 'json'

api_key = ENV['PIPEDRIVE_API_KEY']

if api_key
  pipedriveApiUrl = 'https://api.pipedrive.com/v1/deals?filter_id=2&api_token=' + api_key

  SCHEDULER.every '24h', first_in: 0 do |job|
    open pipedriveApiUrl do |f|
      result = JSON.parse(f.read)
      totalValue = result['data'].map {|d| d['value']}.reduce(&:+)
      send_event('pipedrive-total-deal-value', {current: totalValue})
    end
  end
end
{'fraction_non_alphanumeric': 0.1514500537056928, 'fraction_numerical': 0.011815252416756176, 'mean_word_length': 4.4186046511627906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '2437421', 'n_tokens_mistral': 370, 'n_tokens_neox': 357, 'n_words': 68}