<commit_before>const log = require('winston')
const bank = require('./index')
const db = require('../database/donation')

function filterHandledTransactions(handledTrans) {
    return function(t) {
        const found = handledTrans.find((ht) => {
          return t.id == ht
        })
        return found == undefined
    }
}

module.exports = {
    poll: (opt) => {
      setInterval(() => {
        bank.readTransactions(opt, (data) => {
          db.spent(opt.fromTime, new Date().getTime())
          .then(result => {
            const newTrans = data.filter(filterHandledTransactions(result))

            log.debug('Found ', newTrans.length, ' transactions')
            if (newTrans.length > 0){
              log.debug('Updating database ...')
            }
          })
          .catch(err => {
            log.error(err)
          })
        })
      }, opt.interval)
    },
    today: () => {
      const fromTime = new Date()
      fromTime.setUTCHours(0)
      fromTime.setUTCMinutes(0)
      fromTime.setUTCSeconds(0)
      fromTime.setUTCMilliseconds(0)

      return fromTime.getTime()<commit_msg>poller mapper<commit_after>const log = require('winston')
const bank = require('./index')
const db = require('../database/donation')

function filterHandledTransactions(handledTrans) {
    return function(t) {
        const found = handledTrans.find((ht) => {
          return t.id == ht
        })
        return found == undefined
    }
}

module.exports = {
    poll: (opt) => {
      setInterval(() => {
        bank.readTransactions(opt, (data) => {
          db.spent(opt.fromTime, new Date().getTime())
          .then(result => {
            const newTrans = data.filter(filterHandledTransactions(result))

            log.debug('Found ', newTrans.length, ' transactions')
            if (newTrans.length > 0){
              log.debug('Updating database ...')
              transObjs = newTrans.map((t) => {
                return {
                  _id: t.id,
                  fromId: t.account.id,
                  toId: t.counterparty.id,
                  fromNum: t.account.number,
                  toNum: t.counterparty.number,
                  desc: t.details.description,
                  currency: t.details.value.currency,
                  amount: parseFloat(t.details.value.amount)
                }
                transObjs.forEach(t => {
                    spend(t)
                    .then(r => console.log(r))
                    .catch(e => console.log(e))
                })
              })
              console.log(transObjs)
              log.info('Updating database ...')
            }
          })
          .catch(err => {
            log.error(err)
          })
        })
      }, opt.interval)
    },
    today: () => {
      const fromTime = new Date()
      fromTime.setUTCHours(0)
      fromTime.setUTCMinutes(0)
      fromTime.setUTCSeconds(0)
      fromTime.setUTCMilliseconds(0)

      return fromTime.getTime()
{'fraction_non_alphanumeric': 0.1342281879194631, 'fraction_numerical': 0.003355704697986577, 'mean_word_length': 1.6195079086115993, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '463838', 'n_tokens_mistral': 861, 'n_tokens_neox': 842, 'n_words': 142}