Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
team-friendo
signalboost
Commits
f336460c
Verified
Commit
f336460c
authored
Sep 10, 2020
by
aguestuser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[215] rename `getMatureRecycleRequests` -> `evaluateRecycleRequests`
parent
9253a7ae
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
app/db/repositories/recycleRequest.js
app/db/repositories/recycleRequest.js
+2
-2
app/registrar/phoneNumber/recycle.js
app/registrar/phoneNumber/recycle.js
+1
-1
test/unit/db/repositories/recycleRequest.spec.js
test/unit/db/repositories/recycleRequest.spec.js
+1
-1
test/unit/registrar/phoneNumber/recycle.spec.js
test/unit/registrar/phoneNumber/recycle.spec.js
+5
-5
No files found.
app/db/repositories/recycleRequest.js
View file @
f336460c
...
...
@@ -21,7 +21,7 @@ const destroyMany = phoneNumbers =>
where
:
{
phoneNumber
:
{
[
Op
.
in
]:
phoneNumbers
}
},
})
const
getMatur
eRecycleRequests
=
async
()
=>
{
const
evaluat
eRecycleRequests
=
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
,
getMatur
eRecycleRequests
,
destroyMany
}
module
.
exports
=
{
requestToRecycle
,
evaluat
eRecycleRequests
,
destroyMany
}
app/registrar/phoneNumber/recycle.js
View file @
f336460c
...
...
@@ -47,7 +47,7 @@ const requestToRecycle = async phoneNumbers => {
// () -> Promise<Array<string>>
const
processRecycleRequests
=
async
()
=>
{
try
{
const
{
redeemed
,
toRecycle
}
=
await
recycleRequestRepository
.
getMatur
eRecycleRequests
()
const
{
redeemed
,
toRecycle
}
=
await
recycleRequestRepository
.
evaluat
eRecycleRequests
()
const
recycleResults
=
await
Promise
.
all
(
toRecycle
.
map
(
recycle
))
await
recycleRequestRepository
.
destroyMany
([...
redeemed
,
...
toRecycle
])
const
redeemedChannels
=
await
channelRepository
.
findManyDeep
(
redeemed
)
...
...
test/unit/db/repositories/recycleRequest.spec.js
View file @
f336460c
...
...
@@ -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
.
getMatur
eRecycleRequests
(
values
(
phoneNumbers
))
const
res
=
await
recycleRequestRepository
.
evaluat
eRecycleRequests
(
values
(
phoneNumbers
))
expect
(
res
).
to
.
eql
({
redeemed
:
[
phoneNumbers
.
redeemed
],
toRecycle
:
[
phoneNumbers
.
toRecycle
],
...
...
test/unit/registrar/phoneNumber/recycle.spec.js
View file @
f336460c
...
...
@@ -315,7 +315,7 @@ describe('phone number services -- recycle module', () => {
deepChannelFactory
({
channelPhoneNumber
}),
)
const
toRecycle
=
times
(
3
,
genPhoneNumber
)
let
getMatur
eRecycleRequestsStub
let
evaluat
eRecycleRequestsStub
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
getMatur
eRecycleRequestsStub
=
sinon
.
stub
(
evaluat
eRecycleRequestsStub
=
sinon
.
stub
(
recycleRequestRepository
,
'
getMatur
eRecycleRequests
'
,
'
evaluat
eRecycleRequests
'
,
)
})
...
...
@@ -347,7 +347,7 @@ describe('phone number services -- recycle module', () => {
.
onCall
(
2
)
.
callsFake
(()
=>
Promise
.
reject
(
'
BOOM!
'
))
// overall job succeeds
getMatur
eRecycleRequestsStub
.
returns
(
Promise
.
resolve
({
redeemed
,
toRecycle
}))
evaluat
eRecycleRequestsStub
.
returns
(
Promise
.
resolve
({
redeemed
,
toRecycle
}))
await
processRecycleRequests
()
})
...
...
@@ -375,7 +375,7 @@ describe('phone number services -- recycle module', () => {
})
describe
(
'
when job fails
'
,
()
=>
{
beforeEach
(()
=>
getMatur
eRecycleRequestsStub
.
callsFake
(()
=>
Promise
.
reject
(
'
BOOM!
'
)))
beforeEach
(()
=>
evaluat
eRecycleRequestsStub
.
callsFake
(()
=>
Promise
.
reject
(
'
BOOM!
'
)))
it
(
'
notifies maintainers of error
'
,
async
()
=>
{
await
processRecycleRequests
()
expect
(
notifyMaintainersStub
.
getCall
(
0
).
args
).
to
.
eql
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment