0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Handled week & day interval in population of mrr events

refs https://github.com/TryGhost/Team/issues/635

This is to ensure we don't break migrations for any sites which have
imported external subscriptions which have an interval of 'week' or
'day'

The bump to members-api includes the handling of these intervals for
ongoing population of mrr events
This commit is contained in:
Fabien O'Carroll 2021-05-20 16:52:51 +01:00
parent bbeeb83235
commit 730811fb6e
3 changed files with 27 additions and 5 deletions

View file

@ -29,6 +29,16 @@ module.exports = createTransactionalMigration(
if (interval === 'month') {
return amount;
}
if (interval === 'week') {
return amount * 4;
}
if (interval === 'day') {
return amount * 30;
}
throw new Error(`Unknown Subscription interval "${interval}" found.`);
}
const allEvents = allSubscriptions.reduce((allEventsAcc, subscription) => {
@ -36,6 +46,10 @@ module.exports = createTransactionalMigration(
return allEventsAcc;
}
if (!['year', 'month', 'week', 'day'].includes(subscription.plan_interval)) {
return allEventsAcc;
}
const events = [];
if (subscription.status === 'trialing') {

View file

@ -59,7 +59,7 @@
"@tryghost/kg-mobiledoc-html-renderer": "4.0.0",
"@tryghost/limit-service": "0.5.0",
"@tryghost/magic-link": "1.0.2",
"@tryghost/members-api": "1.9.0",
"@tryghost/members-api": "1.10.0",
"@tryghost/members-csv": "1.0.0",
"@tryghost/members-ssr": "1.0.2",
"@tryghost/mw-session-from-token": "0.1.20",

View file

@ -732,13 +732,14 @@
jsonwebtoken "^8.5.1"
lodash "^4.17.15"
"@tryghost/members-api@1.9.0":
version "1.9.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.9.0.tgz#45c0d563feed8292d8c2dd324341240d669166f6"
integrity sha512-5Ids1Ma5YUQtBGSATSAEVVDKfGUCnccH4GhAha29D04HcbEwYKAj2y4Pv8quYt/NYet7U4RTzq6qxG8jEbJWJQ==
"@tryghost/members-api@1.10.0":
version "1.10.0"
resolved "https://registry.yarnpkg.com/@tryghost/members-api/-/members-api-1.10.0.tgz#f87efa080ce2ff376ce898d56dd48bcd332f8219"
integrity sha512-ILQkzusZsHtL9/OpTzAC2jr+9Ns0dO7naepnJZcfMpuA2YCCjhUBlbv99pRTgYCd5nXECQoK9bdiBEv+Vl1DHw==
dependencies:
"@tryghost/errors" "^0.2.9"
"@tryghost/magic-link" "^1.0.2"
"@types/jsonwebtoken" "^8.5.1"
bluebird "^3.5.4"
body-parser "^1.19.0"
cookies "^0.8.0"
@ -966,6 +967,13 @@
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.0.tgz#9140779736aa2655635ee756e2467d787cfe8a2a"
integrity sha512-c3Xy026kOF7QOTn00hbIllV1dLR9hG9NkSrLQgCVs8NF6sBU+VGWjD3wLPhmh1TYAc7ugCFsvHYMN4VcBN1U1A==
"@types/jsonwebtoken@^8.5.1":
version "8.5.1"
resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#56958cb2d80f6d74352bd2e501a018e2506a8a84"
integrity sha512-rNAPdomlIUX0i0cg2+I+Q1wOUr531zHBQ+cV/28PJ39bSPKjahatZZ2LMuhiguETkCgLVzfruw/ZvNMNkKoSzw==
dependencies:
"@types/node" "*"
"@types/keyv@*":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@types/keyv/-/keyv-3.1.1.tgz#e45a45324fca9dab716ab1230ee249c9fb52cfa7"