Restricted members importer to ignore "products" column
refs https://github.com/TryGhost/Team/issues/1076
refs 70229e4fd3 (diff-b67ecda91b5bd79c598e5c5a9ec2ccf28dbfab6a924b21352273865e07cd7ceaR57)
- The "products" column has not been doing any logic anything since at least 5.20.0 (see refed commit). The concept of columns in the export file was mostly there for analytical/data filtering reasons - so the user could analyze their exports. CSV was never a good suite for relational data that "products" (or now tiers) represent
- The "tiers" column will still be present in the exported CSV file, but there is not going to be any logic attached to it.
- The only columns that can effect the "tiers" state of the member are: "complimentary_plan" (assign default tier to the member) and "stripe_customer_id" (pulls in subscription/tier data from Stripe)
This commit is contained in:
parent
53e20f30ae
commit
840deaf8d7
@ -29,12 +29,6 @@ module.exports = (path, headerMapping, defaultLabels = []) => {
|
||||
}
|
||||
}
|
||||
|
||||
if (header === 'products') {
|
||||
if (value && typeof value === 'string') {
|
||||
return value.split(',').map(name => ({name}));
|
||||
}
|
||||
}
|
||||
|
||||
if (header === 'subscribed') {
|
||||
return value.toLowerCase() !== 'false';
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ third-member-email@email.com,"banana, avocado"`;
|
||||
assert.equal(result, expected);
|
||||
});
|
||||
|
||||
it('handles the tiers to products property serialization', function () {
|
||||
it('handles the tiers property serialization', function () {
|
||||
const json = [{
|
||||
email: 'member-email@email.com',
|
||||
tiers: [{
|
||||
|
@ -21,9 +21,9 @@ const DEFAULT_CSV_HEADER_MAPPING = {
|
||||
created_at: 'created_at',
|
||||
complimentary_plan: 'complimentary_plan',
|
||||
stripe_customer_id: 'stripe_customer_id',
|
||||
labels: 'labels',
|
||||
products: 'products'
|
||||
labels: 'labels'
|
||||
};
|
||||
|
||||
module.exports = class MembersCSVImporter {
|
||||
/**
|
||||
* @param {Object} options
|
||||
@ -159,19 +159,8 @@ module.exports = class MembersCSVImporter {
|
||||
member_id: member.id
|
||||
}, options);
|
||||
} else if (row.complimentary_plan) {
|
||||
if (!row.products) {
|
||||
await membersApi.members.update({
|
||||
products: [{id: defaultProduct.id}]
|
||||
}, {
|
||||
...options,
|
||||
id: member.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (row.products) {
|
||||
await membersApi.members.update({
|
||||
products: row.products
|
||||
products: [{id: defaultProduct.id}]
|
||||
}, {
|
||||
...options,
|
||||
id: member.id
|
||||
|
@ -1,3 +1,3 @@
|
||||
id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,products
|
||||
id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers
|
||||
634e48e056ef99c6a7af5850,member_complimentary_test@example.com,"bobby tables","a note",true,true,,2022-10-18T06:34:08.000Z,,"user import label",This is a Bronze Tier
|
||||
634e566dde68acf282cd311e,member_stripe_test@example.com,"stirpey beaver","testing notes",false,,cus_MdR9tqW6bAreiq,2022-10-18T07:31:57.000Z,,,This is a Premium Tier
|
||||
|
|
@ -25,8 +25,7 @@ describe('Importer', function () {
|
||||
created_at: 'created_at',
|
||||
complimentary_plan: 'complimentary_plan',
|
||||
stripe_customer_id: 'stripe_customer_id',
|
||||
labels: 'labels',
|
||||
products: 'products'
|
||||
labels: 'labels'
|
||||
};
|
||||
|
||||
beforeEach(function () {
|
||||
@ -201,7 +200,7 @@ describe('Importer', function () {
|
||||
should.equal(membersApiStub.members.linkStripeCustomer.args[0][0].customer_id, 'cus_MdR9tqW6bAreiq');
|
||||
should.equal(membersApiStub.members.linkStripeCustomer.args[0][0].member_id, 'test_member_id');
|
||||
|
||||
// products import
|
||||
// complimentary_plan import
|
||||
membersApiStub.members.update.calledOnce.should.be.true();
|
||||
should.deepEqual(membersApiStub.members.update.args[0][0].products, [{
|
||||
id: 'default_product_id'
|
||||
|
Loading…
Reference in New Issue
Block a user