<commit_before>const { difference } = require('lodash')
const setupPool = require('./setup-db-pool')
const { createDecipher } = require('crypto')

async function interval(servers, dbPool, logger, config) {
  const [ rows ] = await dbPool.query('SELECT * FROM bm_web_servers')
  const newIds = rows.map((server) => {
    server.tables = JSON.parse(server.tables)

    if (servers.has(server.id)) {
      // Check for modifications
      const currentServer = servers.get(server.id)
      const diff = JSON.stringify(currentServer.config) !== JSON.stringify(server) // @TODO Use isEqual, but currently causes infinite loop

      if (!diff) return server.id

      // @TODO Only modify pool if connection details have changed
      currentServer.pool.end().catch((error) => logger.error(error, 'servers-pool'))
    }

    let password

    if (server.password) {
      const decipher = createDecipher(config.secrets.encryption.algorithm, config.secrets.encryption.key)
      let decrypted = decipher.update(server.password, 'hex', 'utf8')

      decrypted += decipher.final('utf8')

      password = <PASSWORD>
    }

    const poolConfig =
      { connectionLimit: 5
      , host: server.host
      , port: server.port
      , user: server.user
      , password: password
      , database: server.database
      }
    const pool = setupPool(poolConfig, logger)<commit_msg>Removed config argument from servers pool<commit_after>const { difference } = require('lodash')
const setupPool = require('./setup-db-pool')
const { createDecipher } = require('crypto')

async function interval(servers, dbPool, logger) {
  const [ rows ] = await dbPool.query('SELECT * FROM bm_web_servers')
  const newIds = rows.map((server) => {
    server.tables = JSON.parse(server.tables)

    if (servers.has(server.id)) {
      // Check for modifications
      const currentServer = servers.get(server.id)
      const diff = JSON.stringify(currentServer.config) !== JSON.stringify(server) // @TODO Use isEqual, but currently causes infinite loop

      if (!diff) return server.id

      // @TODO Only modify pool if connection details have changed
      currentServer.pool.end().catch((error) => logger.error(error, 'servers-pool'))
    }

    let password

    if (server.password) {
      const decipher = createDecipher(process.env.ENCRYPTION_ALGORITHM, process.env.ENCRYPTION_KEY)
      let decrypted = decipher.update(server.password, 'hex', 'utf8')

      decrypted += decipher.final('utf8')

      password = decrypted
    }

    const poolConfig =
      { connectionLimit: 5
      , host: server.host
      , port: server.port
      , user: server.user
      , password: password
      , database: server.database
      }
    const pool = setupPool(poolConfig, logger)
{'fraction_non_alphanumeric': 0.12014519056261343, 'fraction_numerical': 0.002177858439201452, 'mean_word_length': 3.22052067381317, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 8, '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': '2992194', 'n_tokens_mistral': 803, 'n_tokens_neox': 783, 'n_words': 197}