2022-10-26 19:55:08 +03:00
|
|
|
const TableImporter = require('./base');
|
|
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
const {luck} = require('../utils/random');
|
|
|
|
|
|
|
|
class MembersCreatedEventsImporter extends TableImporter {
|
2023-02-16 15:11:00 +03:00
|
|
|
static table = 'members_created_events';
|
|
|
|
|
2022-10-26 19:55:08 +03:00
|
|
|
constructor(knex) {
|
2023-02-16 15:11:00 +03:00
|
|
|
super(MembersCreatedEventsImporter.table, knex);
|
2022-10-26 19:55:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
setImportOptions({model}) {
|
|
|
|
this.model = model;
|
|
|
|
}
|
|
|
|
|
|
|
|
generateSource() {
|
|
|
|
let source = 'member';
|
|
|
|
if (luck(10)) {
|
|
|
|
source = 'admin';
|
|
|
|
} else if (luck(5)) {
|
|
|
|
source = 'api';
|
2023-02-06 13:40:18 +03:00
|
|
|
} else if (luck(5)) { // eslint-disable-line no-dupe-else-if
|
|
|
|
source = 'import';
|
2022-10-26 19:55:08 +03:00
|
|
|
}
|
|
|
|
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;
|