<commit_before>export const AGG_WINDOW_AUTO = 'auto'
export const AGG_WINDOW_NONE = 'none'
export const DEFAULT_FILLVALUES = false

export const DURATIONS = [
  '5s',
  '15s',
  '1m',
  '5m',
  '15m',
  '1h',
  '6h',
  '12h',
  '24h',
  '2d',
  '7d',
  '30d',
]

export interface QueryFn {
  name: string
  flux: (period?: string, fillValues?: boolean) => string
}

export const genFlux = (
  func: string,
  period: string,
  fillValues: boolean = false
) => {
  if (period === AGG_WINDOW_NONE) {
    return `|> ${func}()`
  }

  switch (func) {
    case 'derivative': {
      return `|> derivative(unit: ${period}, nonNegative: false)`
    }

    case 'nonnegative derivative': {
      return `|> derivative(unit: ${period}, nonNegative: true)`
    }

    case 'median':
    case 'mean':
    case 'max':
    case 'min':
    case 'sum':
    case 'stddev':
    case 'first':
    case 'last': {
      return `|> aggregateWindow(every: ${period}, fn: ${func}, createEmpty: ${fillValues})`
    }

    default:
      return `|> ${func}()`
  }
}

export const AUTO_FUNCTIONS: QueryFn[] = [
  {<commit_msg>fix(timeMachine): change derivative to 1s (#19776)<commit_after>export const AGG_WINDOW_AUTO = 'auto'
export const AGG_WINDOW_NONE = 'none'
export const DEFAULT_FILLVALUES = false

export const DURATIONS = [
  '5s',
  '15s',
  '1m',
  '5m',
  '15m',
  '1h',
  '6h',
  '12h',
  '24h',
  '2d',
  '7d',
  '30d',
]

export interface QueryFn {
  name: string
  flux: (period?: string, fillValues?: boolean) => string
}

export const genFlux = (
  func: string,
  period: string,
  fillValues: boolean = false
) => {
  if (period === AGG_WINDOW_NONE) {
    return `|> ${func}()`
  }

  switch (func) {
    case 'derivative': {
      return `|> derivative(unit: 1s, nonNegative: false)`
    }

    case 'nonnegative derivative': {
      return `|> derivative(unit: 1s, nonNegative: true)`
    }

    case 'median':
    case 'mean':
    case 'max':
    case 'min':
    case 'sum':
    case 'stddev':
    case 'first':
    case 'last': {
      return `|> aggregateWindow(every: ${period}, fn: ${func}, createEmpty: ${fillValues})`
    }

    default:
      return `|> ${func}()`
  }
}

export const AUTO_FUNCTIONS: QueryFn[] = [
  {
{'fraction_non_alphanumeric': 0.17183985605038238, 'fraction_numerical': 0.018893387314439947, 'mean_word_length': 3.0732600732600734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2002599', 'n_tokens_mistral': 863, 'n_tokens_neox': 814, 'n_words': 205}