<commit_before>class KodingKontrol extends (require 'kontrol')

  constructor: ->
    super @getAuthOptions()

    @kites = {}
    @regions = {}

  getAuthOptions: ->
    autoConnect : no
    url         : @_kontrolUrl ? KD.config.newkontrol.url
    auth        :
      type      : 'sessionID'
      key       : Cookies.get 'clientId'

  reauthenticate: ->
    # disconnect the old kontrol kite
    @kite?.disconnect()
    # reauthenticate with the current session token
    @authenticate @getAuthOptions()

  fetchKites: (query = {}, rest...) ->
    super (@injectQueryParams query), rest...

  getVersion: (name) ->
    return '1.0.0'  unless name?
    { os, terminal, klient } = KD.config.kites
    # TODO: this could be more elegant:
    {
      oskite    : os.version
      terminal  : terminal.version
      klient    : klient.version
    }[name] ? ''

  injectQueryParams: (args) ->

    if args.kontrolUrl? and args.kontrolUrl isnt @_kontrolUrl
      @_kontrolUrl = args.kontrolUrl
      @reauthenticate()

    if @_kontrolUrl? and not args.kontrolUrl?
      delete @_kontrolUrl
      @reauthenticate()

    args.query.version     ?= @getVersion args.query.name
    args.query.username    ?= KD.config.kites.kontrol.username
    args.query.environment ?= KD.config.environment
<commit_msg>KodingKontrol: remove inject trick instead we will pass it as options<commit_after>class KodingKontrol extends (require 'kontrol')

  constructor: (options = {})->

    @_kontrolUrl = options.kontrolUrl  if options.kontrolUrl?

    super @getAuthOptions()

    @kites = {}
    @regions = {}

  getAuthOptions: ->
    autoConnect : no
    url         : @_kontrolUrl ? KD.config.newkontrol.url
    auth        :
      type      : 'sessionID'
      key       : Cookies.get 'clientId'

  reauthenticate: ->
    # disconnect the old kontrol kite
    @kite?.disconnect()
    # reauthenticate with the current session token
    @authenticate @getAuthOptions()

  fetchKites: (query = {}, rest...) ->
    super (@injectQueryParams query), rest...

  getVersion: (name) ->
    return '1.0.0'  unless name?
    { os, terminal, klient } = KD.config.kites
    # TODO: this could be more elegant:
    {
      oskite    : os.version
      terminal  : terminal.version
      klient    : klient.version
    }[name] ? ''

  injectQueryParams: (args) ->

    args.query.version     ?= @getVersion args.query.name
    args.query.username    ?= KD.config.kites.kontrol.username
    args.query.environment ?= KD.config.environment

{'fraction_non_alphanumeric': 0.11607499002792182, 'fraction_numerical': 0.0023932987634623054, 'mean_word_length': 2.5274261603375527, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '655204', 'n_tokens_mistral': 838, 'n_tokens_neox': 772, 'n_words': 184}