<commit_before>_ = require 'underscore'
Utils = require '../models/utils'
DatabaseStore = require './database-store'
ModelView = require './model-view'
EventEmitter = require('events').EventEmitter

verbose = true

# A small helper class that prevents the DatabaseView from making too many
# queries. It tracks the number of jobs in flight via `increment` and allows
# a callback to run "when there are fewer then N ongoing queries".
# Sort of like _.throttle, but with a work threshold rather than a time threshold.
class TaskThrottler
  constructor: (@_maxConcurrent) ->
    @_inflight = 0
    @_whenReady = null

  whenReady: (fn) ->
    if @_inflight < @_maxConcurrent
      fn()
    else
      @_whenReady = fn

  increment: ->
    decremented = false
    @_inflight += 1

    # Returns a function that can be called once and only once to
    # decrement the counter.<commit_msg>fix(db): Disable verbose warnings from DatabaseView<commit_after>_ = require 'underscore'
Utils = require '../models/utils'
DatabaseStore = require './database-store'
ModelView = require './model-view'
EventEmitter = require('events').EventEmitter

verbose = false

# A small helper class that prevents the DatabaseView from making too many
# queries. It tracks the number of jobs in flight via `increment` and allows
# a callback to run "when there are fewer then N ongoing queries".
# Sort of like _.throttle, but with a work threshold rather than a time threshold.
class TaskThrottler
  constructor: (@_maxConcurrent) ->
    @_inflight = 0
    @_whenReady = null

  whenReady: (fn) ->
    if @_inflight < @_maxConcurrent
      fn()
    else
      @_whenReady = fn

  increment: ->
    decremented = false
    @_inflight += 1

    # Returns a function that can be called once and only once to
    # decrement the counter.
{'fraction_non_alphanumeric': 0.08688433868289984, 'fraction_numerical': 0.002213613724405091, 'mean_word_length': 3.4975124378109452, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4211835', 'n_tokens_mistral': 511, 'n_tokens_neox': 503, 'n_words': 212}