d2cb23c3fa
ref PROD-233 - Stored whether Docker is used in the config files - When running `yarn setup`, any existing Docker container will be reset. Run with `-y` to skip the confirmation step. - `yarn setup` will always init the database and generate fake data - Increased amount of default generated data to 100,000 members + 500 posts. - Made lots of performance improvements in the data generator so we can generate the default data in ±170s
42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
const TableImporter = require('./TableImporter');
|
|
const {faker} = require('@faker-js/faker');
|
|
const {slugify} = require('@tryghost/string');
|
|
const {blogStartDate} = require('../utils/blog-info');
|
|
const dateToDatabaseString = require('../utils/database-date');
|
|
|
|
class LabelsImporter extends TableImporter {
|
|
static table = 'labels';
|
|
static dependencies = [];
|
|
defaultQuantity = 10;
|
|
|
|
constructor(knex, transaction) {
|
|
super(LabelsImporter.table, knex, transaction);
|
|
this.generatedNames = new Set();
|
|
}
|
|
|
|
generateName() {
|
|
let name;
|
|
do {
|
|
name = `${faker.color.human()} ${faker.name.jobType()}`;
|
|
name = `${name[0].toUpperCase()}${name.slice(1)}`;
|
|
} while (this.generatedNames.has(name));
|
|
this.generatedNames.add(name);
|
|
return name;
|
|
}
|
|
|
|
generate() {
|
|
const name = this.generateName();
|
|
return {
|
|
id: this.fastFakeObjectId(),
|
|
name: name,
|
|
slug: `${slugify(name)}`,
|
|
created_at: dateToDatabaseString(blogStartDate),
|
|
created_by: '1',
|
|
updated_at: dateToDatabaseString(blogStartDate),
|
|
updated_by: '1'
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = LabelsImporter;
|