<commit_before>import os from 'os'
import pg from 'pg'
import { URL } from 'url'

const createPoolConnections = function (config, log) {
  const myDb = new URL(config.databaseUrl)
  const pool = new pg.Pool({
    user: myDb.username,
    database: myDb.pathname.substr(1),
    password: <PASSWORD>,
    host: myDb.hostname,
    port: myDb.port,
    max: 10,
    idleTimeoutMillis: 30000,
  })

  pool.on('error', function (err) {
    log.error('idle pool error', err.message, err.stack)
  })

  log.info('Opened pool connection')
  return pool
}

// https://github.com/FastIT/health-check
const checkPostgres = function (config, log, res) {
  const pool = createPoolConnections(config, log)

  pool.query('SELECT NOW() AS "the_time"', function (err, resDb) {
    if (err) {
      log.info(err)
      return res.json({ status: 'ko', online: false, error: err })
    }

    return res.json({
      online: true,
      os: {
        arch: os.arch(),
        loadavg: os.loadavg(),
        freemem: os.freemem(),
        platform: os.platform(),
        totalmem: os.totalmem(),
        uptime: os.uptime(),
        release: os.release(),
      },
      resDb,
      process: {
        execArgv: process.execArgv,
        execPath: process.execPath,
        memoryUsage: process.memoryUsage(),
        pid: process.pid,
        platform: process.platform,
        uptime: process.uptime(),
      },
      uptime: process.uptime(),
      status: 'ok',
    })
  })
}

export default {
  createPoolConnections,
  checkPostgres
}
<commit_msg>Remove log when open db connection<commit_after>import os from 'os'
import pg from 'pg'
import { URL } from 'url'

const createPoolConnections = function (config, log) {
  const myDb = new URL(config.databaseUrl)
  const pool = new pg.Pool({
    user: myDb.username,
    database: myDb.pathname.substr(1),
    password: <PASSWORD>,
    host: myDb.hostname,
    port: myDb.port,
    max: 10,
    idleTimeoutMillis: 30000,
  })

  pool.on('error', function (err) {
    log.error('idle pool error', err.message, err.stack)
  })

  return pool
}

// https://github.com/FastIT/health-check
const checkPostgres = function (config, log, res) {
  const pool = createPoolConnections(config, log)

  pool.query('SELECT NOW() AS "the_time"', function (err, resDb) {
    if (err) {
      log.info(err)
      return res.json({ status: 'ko', online: false, error: err })
    }

    return res.json({
      online: true,
      os: {
        arch: os.arch(),
        loadavg: os.loadavg(),
        freemem: os.freemem(),
        platform: os.platform(),
        totalmem: os.totalmem(),
        uptime: os.uptime(),
        release: os.release(),
      },
      resDb,
      process: {
        execArgv: process.execArgv,
        execPath: process.execPath,
        memoryUsage: process.memoryUsage(),
        pid: process.pid,
        platform: process.platform,
        uptime: process.uptime(),
      },
      uptime: process.uptime(),
      status: 'ok',
    })
  })
}

export default {
  createPoolConnections,
  checkPostgres
}

{'fraction_non_alphanumeric': 0.13794233289646135, 'fraction_numerical': 0.005242463958060288, 'mean_word_length': 2.55, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6393673', 'n_tokens_mistral': 1015, 'n_tokens_neox': 994, 'n_words': 246}