mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-03 13:20:57 +00:00
Merge pull request #12757 from overleaf/bg-clean-up-recurly-prices-script
clean up recurly prices script GitOrigin-RevId: b9afa05a0931bb11fd9be2d9a92a6d4beaab2f7d
This commit is contained in:
parent
253f44894a
commit
72abda9f29
1 changed files with 17 additions and 3 deletions
|
@ -45,7 +45,11 @@ async function getRecurlyPlanAddOns(plan) {
|
||||||
})
|
})
|
||||||
const result = []
|
const result = []
|
||||||
for await (const addOn of addOns.each()) {
|
for await (const addOn of addOns.each()) {
|
||||||
result.push(addOn)
|
if (addOn.code === 'additional-license') {
|
||||||
|
result.push(addOn)
|
||||||
|
} else {
|
||||||
|
console.error('UNRECOGNISED ADD-ON CODE', plan.code, addOn.code)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -131,7 +135,17 @@ async function updatePlanAddOn(plan, localAddOn) {
|
||||||
}
|
}
|
||||||
const planCodeId = `code-${plan.code}`
|
const planCodeId = `code-${plan.code}`
|
||||||
const addOnId = 'code-additional-license'
|
const addOnId = 'code-additional-license'
|
||||||
const originalPlanAddOn = await client.getPlanAddOn(planCodeId, addOnId)
|
let originalPlanAddOn
|
||||||
|
try {
|
||||||
|
originalPlanAddOn = await client.getPlanAddOn(planCodeId, addOnId)
|
||||||
|
} catch (error) {
|
||||||
|
if (error instanceof recurly.errors.NotFoundError) {
|
||||||
|
console.error('plan add-on not found', planCodeId, addOnId)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
const changes = _.differenceWith(
|
const changes = _.differenceWith(
|
||||||
localAddOn.currencies,
|
localAddOn.currencies,
|
||||||
originalPlanAddOn.currencies,
|
originalPlanAddOn.currencies,
|
||||||
|
@ -146,7 +160,7 @@ async function updatePlanAddOn(plan, localAddOn) {
|
||||||
const planAddOnUpdate = { currencies: localAddOn.currencies }
|
const planAddOnUpdate = { currencies: localAddOn.currencies }
|
||||||
try {
|
try {
|
||||||
if (DRY_RUN) {
|
if (DRY_RUN) {
|
||||||
console.error('skipping update to additional licencse for', planCodeId)
|
console.error('skipping update to additional license for', planCodeId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const newPlanAddOn = await client.updatePlanAddOn(
|
const newPlanAddOn = await client.updatePlanAddOn(
|
||||||
|
|
Loading…
Reference in a new issue