mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-27 21:03:29 +03:00
28b11e6fed
refs: https://github.com/TryGhost/Toolbox/issues/440 New command to generate demo data, creates data for over 20 tables in Ghost, suitable for testing most features of the dashboard, as well as making guided product tours using newsletters, tiers, many posts and tags. Usage: `yarn start generate-data` Optionally, keep your existing posts / tags with: `yarn start generate-data --use-existing-tags --use-existing-posts`
36 lines
850 B
JavaScript
36 lines
850 B
JavaScript
const TableImporter = require('./base');
|
|
const {faker} = require('@faker-js/faker');
|
|
const {luck} = require('../utils/random');
|
|
|
|
class MembersCreatedEventsImporter extends TableImporter {
|
|
constructor(knex) {
|
|
super('members_created_events', knex);
|
|
}
|
|
|
|
setImportOptions({model}) {
|
|
this.model = model;
|
|
}
|
|
|
|
generateSource() {
|
|
let source = 'member';
|
|
if (luck(10)) {
|
|
source = 'admin';
|
|
} else if (luck(5)) {
|
|
source = 'api';
|
|
}
|
|
return source;
|
|
}
|
|
|
|
generate() {
|
|
// TODO: Add attribution
|
|
return {
|
|
id: faker.database.mongodbObjectId(),
|
|
created_at: this.model.created_at,
|
|
member_id: this.model.id,
|
|
source: this.generateSource()
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = MembersCreatedEventsImporter;
|