2022-10-26 19:55:08 +03:00
|
|
|
const TableImporter = require('./base');
|
|
|
|
const {blogStartDate} = require('../utils/blog-info');
|
|
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
const {slugify} = require('@tryghost/string');
|
|
|
|
|
|
|
|
class NewslettersImporter extends TableImporter {
|
2023-02-16 15:11:00 +03:00
|
|
|
static table = 'newsletters';
|
|
|
|
|
2022-10-26 19:55:08 +03:00
|
|
|
constructor(knex) {
|
2023-02-16 15:11:00 +03:00
|
|
|
super(NewslettersImporter.table, knex);
|
2022-10-26 19:55:08 +03:00
|
|
|
this.sortOrder = 0;
|
2023-02-09 01:12:19 +03:00
|
|
|
this.names = ['Regular premium', 'Occasional freebie'];
|
2022-10-26 19:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
generate() {
|
|
|
|
const name = this.names.shift();
|
|
|
|
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(),
|
|
|
|
name: name,
|
|
|
|
slug: `${slugify(name)}-${faker.random.numeric(3)}`,
|
|
|
|
sender_reply_to: 'hello@example.com',
|
|
|
|
status: 'active',
|
|
|
|
subscribe_on_signup: faker.datatype.boolean(),
|
|
|
|
sort_order: sortOrder,
|
|
|
|
created_at: faker.date.between(blogStartDate, weekAfter)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = NewslettersImporter;
|