mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
e0bcb26600
no issue This makes the data-generator more customisable.
38 lines
950 B
JavaScript
38 lines
950 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';
|
|
} else if (luck(5)) { // eslint-disable-line no-dupe-else-if
|
|
source = 'import';
|
|
}
|
|
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;
|