<commit_before>const es = require('event-stream')
module.exports = (app) => {
  app.middleware('routes:before', function (req, res, next) {
    if (req.path.indexOf('change-stream') !== -1) {
      res.setTimeout(24 * 3600 * 1000)
      res.set('X-Accel-Buffering', 'no')
    }
    return next()
  })

  const Notification = app.models.Notification
  Notification.createChangeStream((err, changes) => {
    if (err) console.log(err)
    changes.pipe(es.stringify()).pipe(process.stdout)
  })
}

// const es = require('event-stream')
//<commit_msg>implement realtime change stream on post model<commit_after>const es = require('event-stream')
module.exports = (app) => {
  app.middleware('routes:before', function (req, res, next) {
    if (req.path.indexOf('change-stream') !== -1) {
      res.setTimeout(24 * 3600 * 1000)
      res.set('X-Accel-Buffering', 'no')
    }
    return next()
  })

  const Notification = app.models.Notification
  Notification.createChangeStream((err, changes) => {
    if (err) console.log(err)
    changes.pipe(es.stringify()).pipe(process.stdout)
  })

  const Post = app.models.post
  Post.createChangeStream((err, changes) => {
    if (err) console.error(err)
    changes.pipe(es.stringify()).pipe(process.stdout)
  })

}

// const es = require('event-stream')
//
{'fraction_non_alphanumeric': 0.17579028527370855, 'fraction_numerical': 0.016962220508866616, 'mean_word_length': 3.6357142857142857, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6402537', 'n_tokens_mistral': 445, 'n_tokens_neox': 424, 'n_words': 79}