Ghost/ghost/data-generator/lib/tables/members-created-events.js
Sam Lord e0bcb26600 Improved data-generator tooling
no issue

This makes the data-generator more customisable.
2023-02-06 10:42:56 +00:00

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;