<commit_before>module.exports = function init(params) {
  const emails = params.emails;
  const knex = params.knex;
  const util = params.util;
  const service = require('./services/adNotifications')({ knex, util });

  function testSending(req, res, next) {
    service.notificationObjects()
      .then(objects => res.json(objects))
  }

  return {
    testSending
  };
}<commit_msg>Save in DB send status<commit_after>module.exports = function init(params) {
  const emails = params.emails;
  const knex = params.knex;
  const util = params.util;
  const service = require('./services/adNotifications')({ knex, util });

  function testSending(req, res, next) {
    service.notificationObjects()
      .then(notifications => {
        const promises = notifications.map(notification => {
          const user = notification.user;
          const notificationRows = notification.ads.map(ad => ({
            ad_id: ad.id,
            user_id: user.id
          }))
          return knex('user_ad_notifications').insert(notificationRows)
            .then(() => notifications)
        });
        return Promise.all(promises);
      })
      .then(objects => res.json(objects))
  }

  return {
    testSending
  };
}
{'fraction_non_alphanumeric': 0.12900575184880855, 'fraction_numerical': 0.0, 'mean_word_length': 2.80625, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4007000', 'n_tokens_mistral': 357, 'n_tokens_neox': 350, 'n_words': 76}