Verified Commit f336460c authored by aguestuser's avatar aguestuser

[215] rename `getMatureRecycleRequests` -> `evaluateRecycleRequests`

parent 9253a7ae
......@@ -21,7 +21,7 @@ const destroyMany = phoneNumbers =>
where: { phoneNumber: { [Op.in]: phoneNumbers } },
})
const getMatureRecycleRequests = async () => {
const evaluateRecycleRequests = async () => {
// channel admins have a 1 day grace period to redeem a channel slated for recycling
// by using it. calculate when that grace period started...
const gracePeriodStart = util.now().subtract(parseInt(recycleGracePeriod), 'ms')
......@@ -48,4 +48,4 @@ const getMatureRecycleRequests = async () => {
}
}
module.exports = { requestToRecycle, getMatureRecycleRequests, destroyMany }
module.exports = { requestToRecycle, evaluateRecycleRequests, destroyMany }
......@@ -47,7 +47,7 @@ const requestToRecycle = async phoneNumbers => {
// () -> Promise<Array<string>>
const processRecycleRequests = async () => {
try {
const { redeemed, toRecycle } = await recycleRequestRepository.getMatureRecycleRequests()
const { redeemed, toRecycle } = await recycleRequestRepository.evaluateRecycleRequests()
const recycleResults = await Promise.all(toRecycle.map(recycle))
await recycleRequestRepository.destroyMany([...redeemed, ...toRecycle])
const redeemedChannels = await channelRepository.findManyDeep(redeemed)
......
......@@ -131,7 +131,7 @@ describe('recycleablePhoneNumber repository', () => {
})
it('retrieves all mature recycle requests and classifies them as redeemed or toRecycle', async () => {
const res = await recycleRequestRepository.getMatureRecycleRequests(values(phoneNumbers))
const res = await recycleRequestRepository.evaluateRecycleRequests(values(phoneNumbers))
expect(res).to.eql({
redeemed: [phoneNumbers.redeemed],
toRecycle: [phoneNumbers.toRecycle],
......
......@@ -315,7 +315,7 @@ describe('phone number services -- recycle module', () => {
deepChannelFactory({ channelPhoneNumber }),
)
const toRecycle = times(3, genPhoneNumber)
let getMatureRecycleRequestsStub
let evaluateRecycleRequestsStub
beforeEach(() => {
// recycle helpers that should always succeed
......@@ -330,9 +330,9 @@ describe('phone number services -- recycle module', () => {
notifyAdminsStub.returns(Promise.resolve(['42', '42']))
// if this fails, processRecycleRequests will fail
getMatureRecycleRequestsStub = sinon.stub(
evaluateRecycleRequestsStub = sinon.stub(
recycleRequestRepository,
'getMatureRecycleRequests',
'evaluateRecycleRequests',
)
})
......@@ -347,7 +347,7 @@ describe('phone number services -- recycle module', () => {
.onCall(2)
.callsFake(() => Promise.reject('BOOM!'))
// overall job succeeds
getMatureRecycleRequestsStub.returns(Promise.resolve({ redeemed, toRecycle }))
evaluateRecycleRequestsStub.returns(Promise.resolve({ redeemed, toRecycle }))
await processRecycleRequests()
})
......@@ -375,7 +375,7 @@ describe('phone number services -- recycle module', () => {
})
describe('when job fails', () => {
beforeEach(() => getMatureRecycleRequestsStub.callsFake(() => Promise.reject('BOOM!')))
beforeEach(() => evaluateRecycleRequestsStub.callsFake(() => Promise.reject('BOOM!')))
it('notifies maintainers of error', async () => {
await processRecycleRequests()
expect(notifyMaintainersStub.getCall(0).args).to.eql([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment