2023-08-02 16:43:26 +03:00
|
|
|
const TableImporter = require('./TableImporter');
|
2022-10-26 19:55:08 +03:00
|
|
|
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';
|
2023-08-02 16:43:26 +03:00
|
|
|
static dependencies = [];
|
2023-12-07 14:18:49 +03:00
|
|
|
|
2023-08-02 16:43:26 +03:00
|
|
|
defaultQuantity = 2;
|
2023-02-16 15:11:00 +03:00
|
|
|
|
2023-12-07 14:18:49 +03:00
|
|
|
sortOrder = 0;
|
|
|
|
|
2023-08-02 16:43:26 +03:00
|
|
|
constructor(knex, transaction) {
|
|
|
|
super(NewslettersImporter.table, knex, transaction);
|
2022-10-26 19:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
generate() {
|
2023-12-07 14:18:49 +03:00
|
|
|
const name = `${faker.commerce.productAdjective()} ${faker.word.noun()}`;
|
2022-10-26 19:55:08 +03:00
|
|
|
const sortOrder = this.sortOrder;
|
|
|
|
this.sortOrder = this.sortOrder + 1;
|
2023-12-07 14:18:49 +03:00
|
|
|
|
2022-10-26 19:55:08 +03:00
|
|
|
const weekAfter = new Date(blogStartDate);
|
|
|
|
weekAfter.setDate(weekAfter.getDate() + 7);
|
2023-12-07 14:18:49 +03:00
|
|
|
|
2022-10-26 19:55:08 +03:00
|
|
|
return {
|
2024-01-05 16:42:30 +03:00
|
|
|
id: this.fastFakeObjectId(),
|
2022-10-26 19:55:08 +03:00
|
|
|
uuid: faker.datatype.uuid(),
|
|
|
|
name: name,
|
|
|
|
slug: `${slugify(name)}-${faker.random.numeric(3)}`,
|
2023-03-22 17:56:44 +03:00
|
|
|
sender_reply_to: 'newsletter',
|
2022-10-26 19:55:08 +03:00
|
|
|
status: 'active',
|
|
|
|
subscribe_on_signup: faker.datatype.boolean(),
|
|
|
|
sort_order: sortOrder,
|
|
|
|
created_at: faker.date.between(blogStartDate, weekAfter)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = NewslettersImporter;
|