2022-10-26 19:55:08 +03:00
|
|
|
const TableImporter = require('./base');
|
|
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
|
|
|
|
class MembersSubscriptionCreatedEventsImporter extends TableImporter {
|
2023-02-16 15:11:00 +03:00
|
|
|
static table = 'members_subscription_created_events';
|
|
|
|
|
2022-10-26 19:55:08 +03:00
|
|
|
constructor(knex, {subscriptions}) {
|
2023-02-16 15:11:00 +03:00
|
|
|
super(MembersSubscriptionCreatedEventsImporter.table, knex);
|
2022-10-26 19:55:08 +03:00
|
|
|
this.subscriptions = subscriptions;
|
|
|
|
}
|
|
|
|
|
|
|
|
setImportOptions({model}) {
|
|
|
|
this.model = model;
|
|
|
|
}
|
|
|
|
|
|
|
|
generate() {
|
2023-02-27 15:40:53 +03:00
|
|
|
const subscription = this.subscriptions.find(s => s.id === this.model.ghost_subscription_id);
|
2022-10-26 19:55:08 +03:00
|
|
|
return {
|
|
|
|
id: faker.database.mongodbObjectId(),
|
|
|
|
created_at: subscription.created_at,
|
|
|
|
member_id: subscription.member_id,
|
|
|
|
subscription_id: this.model.id,
|
|
|
|
// TODO: Implement attributions
|
|
|
|
attribution_id: null,
|
|
|
|
attribution_type: null,
|
|
|
|
attribution_url: null,
|
|
|
|
// TODO: Implement referrers
|
|
|
|
referrer_source: null,
|
|
|
|
referrer_medium: null,
|
|
|
|
referrer_url: null
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = MembersSubscriptionCreatedEventsImporter;
|