lamassu-server/lib/compliance-triggers.js
2020-10-06 23:19:22 +02:00

17 lines
No EOL
626 B
JavaScript

const _ = require('lodash/fp')
function getBackwardsCompatibleTriggers (triggers) {
const filtered = _.filter(_.matches({ triggerType: 'txVolume', direction: 'both', thresholdDays: 1 }))(triggers)
const grouped = _.groupBy(_.prop('requirement'))(filtered)
return _.mapValues(_.compose(_.get('threshold'), _.minBy('threshold')))(grouped)
}
function hasSanctions (triggers) {
return _.some(_.matches({ requirement: 'sanctions' }))(triggers)
}
function maxDaysThreshold (triggers) {
return _.max(_.map('thresholdDays')(triggers))
}
module.exports = { getBackwardsCompatibleTriggers, hasSanctions, maxDaysThreshold }