mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 01:03:23 +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`
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const TableImporter = require('./base');
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
class MembersStatusEventsImporter extends TableImporter {
|
|
constructor(knex) {
|
|
super('members_status_events', knex);
|
|
}
|
|
|
|
setImportOptions({model}) {
|
|
this.events = [{
|
|
id: faker.database.mongodbObjectId(),
|
|
member_id: model.id,
|
|
from_status: null,
|
|
to_status: 'free',
|
|
created_at: model.created_at
|
|
}];
|
|
if (model.status !== 'free') {
|
|
this.events.push({
|
|
id: faker.database.mongodbObjectId(),
|
|
member_id: model.id,
|
|
from_status: 'free',
|
|
to_status: model.status,
|
|
created_at: faker.date.between(new Date(model.created_at), new Date()).toISOString()
|
|
});
|
|
}
|
|
}
|
|
|
|
generate() {
|
|
const event = this.events.shift();
|
|
if (!event) {
|
|
return null;
|
|
}
|
|
return event;
|
|
}
|
|
}
|
|
|
|
module.exports = MembersStatusEventsImporter;
|