Created
May 19, 2023 17:10
-
-
Save onosendi/6bfad606572c845a405bd9ed208ef2b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const R = require('ramda'); | |
const xs = [ | |
{ | |
agent: 'Kim', ring_time: 1, queue_id: 1, talk_time: 0, | |
}, | |
{ | |
agent: 'Frank', ring_time: 1, queue_id: 1, talk_time: 0, | |
}, | |
{ | |
agent: 'Kayla', ring_time: 1, queue_id: 1, talk_time: 1, | |
}, | |
{ | |
agent: 'Jon', ring_time: 1, queue_id: 1, talk_time: 0, | |
}, | |
{ | |
agent: 'Myke', ring_time: 0, queue_id: 1, talk_time: 0, | |
}, | |
{ | |
agent: 'Dan', ring_time: 1, queue_id: 1, talk_time: 0, | |
}, | |
]; | |
const getMissedTransferLegs = R.ifElse( | |
R.find((o) => o.agent && o.talk_time > 0), | |
R.pipe( | |
R.takeLastWhile((o) => !(o.agent && o.talk_time > 0)), | |
R.filter((o) => o.agent && o.ring_time > 0 && o.talk_time === 0), | |
), | |
R.always([]), | |
); | |
console.log(getMissedTransferLegs(xs)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment