From e1ef7c44d88f12665c1175649a6d3a921cd7dcab Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Wed, 13 Dec 2023 15:23:21 +0100 Subject: [PATCH] Fixed creating stripe subscriptions for complimentary members in data generator ref PROD-244 --- .../lib/importers/MembersStripeCustomersImporter.js | 2 +- ghost/data-generator/lib/importers/SubscriptionsImporter.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ghost/data-generator/lib/importers/MembersStripeCustomersImporter.js b/ghost/data-generator/lib/importers/MembersStripeCustomersImporter.js index 832277f310..dea9a886e2 100644 --- a/ghost/data-generator/lib/importers/MembersStripeCustomersImporter.js +++ b/ghost/data-generator/lib/importers/MembersStripeCustomersImporter.js @@ -10,7 +10,7 @@ class MembersStripeCustomersImporter extends TableImporter { } async import(quantity) { - const members = await this.transaction.select('id', 'name', 'email', 'created_at').from('members'); + const members = await this.transaction.select('id', 'name', 'email', 'created_at').from('members').where('status', 'paid'); await this.importForEach(members, quantity ? quantity / members.length : 1); } diff --git a/ghost/data-generator/lib/importers/SubscriptionsImporter.js b/ghost/data-generator/lib/importers/SubscriptionsImporter.js index 2172fc0833..8cab70d202 100644 --- a/ghost/data-generator/lib/importers/SubscriptionsImporter.js +++ b/ghost/data-generator/lib/importers/SubscriptionsImporter.js @@ -13,7 +13,7 @@ class SubscriptionsImporter extends TableImporter { async import() { const membersProducts = await this.transaction.select('member_id', 'product_id').from('members_products'); - this.members = await this.transaction.select('id', 'status', 'created_at').from('members'); + this.members = await this.transaction.select('id', 'status', 'created_at').from('members').where('status', 'paid'); this.stripeProducts = await this.transaction.select('product_id', 'stripe_product_id').from('stripe_products'); this.stripePrices = await this.transaction.select('stripe_product_id', 'currency', 'amount', 'interval').from('stripe_prices'); await this.importForEach(membersProducts, 1); @@ -21,6 +21,9 @@ class SubscriptionsImporter extends TableImporter { generate() { const member = this.members.find(m => m.id === this.model.member_id); + if (!member) { + return; + } const status = member.status; const billingInfo = {}; const isMonthly = faker.datatype.boolean();