From 5351b88b592ea1b914d14cc01679cdc4817bcf73 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Wed, 13 Dec 2023 15:31:52 +0100 Subject: [PATCH] Added random expiry date for complimentary subscriptions in data generator ref PROD-244 --- ghost/data-generator/lib/importers/MembersProductsImporter.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghost/data-generator/lib/importers/MembersProductsImporter.js b/ghost/data-generator/lib/importers/MembersProductsImporter.js index ff4a565225..631f563cf1 100644 --- a/ghost/data-generator/lib/importers/MembersProductsImporter.js +++ b/ghost/data-generator/lib/importers/MembersProductsImporter.js @@ -1,6 +1,7 @@ const {faker} = require('@faker-js/faker'); const TableImporter = require('./TableImporter'); const {luck} = require('../utils/random'); +const dateToDatabaseString = require('../utils/database-date'); class MembersProductsImporter extends TableImporter { static table = 'members_products'; @@ -32,7 +33,8 @@ class MembersProductsImporter extends TableImporter { id: faker.database.mongodbObjectId(), member_id: this.model.id, product_id: this.getProduct().id, - sort_order: 0 + sort_order: 0, + expiry_at: this.model.status === 'paid' ? null : (luck(50) ? null : dateToDatabaseString(faker.date.future())) }; } }