mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Fixed generating duplicate newsletter names
refs https://github.com/TryGhost/DevOps/issues/119 - this switches away from using a static list of names in favor of ones generated by faker, so we don't run into duplicate names - also minor code re-arranging
This commit is contained in:
parent
8197a740b1
commit
739c690a29
@ -6,21 +6,23 @@ const {slugify} = require('@tryghost/string');
|
||||
class NewslettersImporter extends TableImporter {
|
||||
static table = 'newsletters';
|
||||
static dependencies = [];
|
||||
|
||||
defaultQuantity = 2;
|
||||
|
||||
sortOrder = 0;
|
||||
|
||||
constructor(knex, transaction) {
|
||||
super(NewslettersImporter.table, knex, transaction);
|
||||
this.sortOrder = 0;
|
||||
// TODO: Use random names if we ever need more than 2 newsletters
|
||||
this.names = ['Regular premium', 'Occasional freebie'];
|
||||
}
|
||||
|
||||
generate() {
|
||||
const name = this.names.shift();
|
||||
const name = `${faker.commerce.productAdjective()} ${faker.word.noun()}`;
|
||||
const sortOrder = this.sortOrder;
|
||||
this.sortOrder = this.sortOrder + 1;
|
||||
|
||||
const weekAfter = new Date(blogStartDate);
|
||||
weekAfter.setDate(weekAfter.getDate() + 7);
|
||||
|
||||
return {
|
||||
id: faker.database.mongodbObjectId(),
|
||||
uuid: faker.datatype.uuid(),
|
||||
|
Loading…
Reference in New Issue
Block a user