<commit_before>require 'dogapi'
require 'parallel'

module Dashdog
  class Client

    def initialize
      @api = Dogapi::Client.new(ENV['DD_API_KEY'], ENV['DD_APP_KEY'])
    end

    def get_timeboards
      ret = []
      Parallel.each(@api.get_dashboards[1]['dashes'], in_threads: 8)  do |bd|
        ret << @api.get_dashboard(bd['id'])[1]['dash']
      end
      return ret
    end

    def get_screenboards
      ret = []
      Parallel.each(@api.get_all_screenboards[1]['screenboards'], in_threads: 8) do |bd|
        ret << @api.get_screenboard(bd['id'])[1]
      end
      return ret
    end

    def create_timeboard(tb)
      ret = @api.create_dashboard(
        tb['title'],
        tb['description'],
        tb['graphs'],
        tb['template_variables'])
      raise RuntimeError, ret[1]['errors'] if ret[0] != '200'
    end

    def update_timeboard(tb)
      ret = @api.update_dashboard(
        tb['id'],
        tb['title'],
        tb['description'],
        tb['graphs'],
        tb['template_variables'])
      raise RuntimeError, ret[1]['errors'] if ret[0] != '200'
    end

    def delete_timeboard(id)
      ret = @api.delete_dashboard(id)
      raise RuntimeError, ret[1]['errors'] if ret[0] != '200'
    end

    def create_screenboard(sb)<commit_msg>'delete timeboard' API returns 204 when the deletion was successful<commit_after>require 'dogapi'
require 'parallel'

module Dashdog
  class Client

    def initialize
      @api = Dogapi::Client.new(ENV['DD_API_KEY'], ENV['DD_APP_KEY'])
    end

    def get_timeboards
      ret = []
      Parallel.each(@api.get_dashboards[1]['dashes'], in_threads: 8)  do |bd|
        ret << @api.get_dashboard(bd['id'])[1]['dash']
      end
      return ret
    end

    def get_screenboards
      ret = []
      Parallel.each(@api.get_all_screenboards[1]['screenboards'], in_threads: 8) do |bd|
        ret << @api.get_screenboard(bd['id'])[1]
      end
      return ret
    end

    def create_timeboard(tb)
      ret = @api.create_dashboard(
        tb['title'],
        tb['description'],
        tb['graphs'],
        tb['template_variables'])
      raise RuntimeError, ret[1]['errors'] if ret[0] != '200'
    end

    def update_timeboard(tb)
      ret = @api.update_dashboard(
        tb['id'],
        tb['title'],
        tb['description'],
        tb['graphs'],
        tb['template_variables'])
      raise RuntimeError, ret[1]['errors'] if ret[0] != '200'
    end

    def delete_timeboard(id)
      ret = @api.delete_dashboard(id)
      raise RuntimeError, ret[1]['errors'] if ret[0] != '204'
    end

    def create_screenboard(sb)
{'fraction_non_alphanumeric': 0.1478927203065134, 'fraction_numerical': 0.017241379310344827, 'mean_word_length': 2.687853107344633, 'pattern_counts': {'":': 0, '<': 11, '<?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': '3179617', 'n_tokens_mistral': 876, 'n_tokens_neox': 842, 'n_words': 180}