Added random expiry date for complimentary subscriptions in data generator

ref PROD-244
This commit is contained in:
Simon Backx 2023-12-13 15:31:52 +01:00 committed by Simon Backx
parent e1ef7c44d8
commit 5351b88b59

View File

@ -1,6 +1,7 @@
const {faker} = require('@faker-js/faker'); const {faker} = require('@faker-js/faker');
const TableImporter = require('./TableImporter'); const TableImporter = require('./TableImporter');
const {luck} = require('../utils/random'); const {luck} = require('../utils/random');
const dateToDatabaseString = require('../utils/database-date');
class MembersProductsImporter extends TableImporter { class MembersProductsImporter extends TableImporter {
static table = 'members_products'; static table = 'members_products';
@ -32,7 +33,8 @@ class MembersProductsImporter extends TableImporter {
id: faker.database.mongodbObjectId(), id: faker.database.mongodbObjectId(),
member_id: this.model.id, member_id: this.model.id,
product_id: this.getProduct().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()))
}; };
} }
} }