Ghost/ghost/data-generator/lib/tables/members-subscription-created-events.js
Sam Lord 28b11e6fed
Added command to generate demo data (#15691)
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`
2022-10-26 17:55:08 +01:00

34 lines
1.0 KiB
JavaScript

const TableImporter = require('./base');
const {faker} = require('@faker-js/faker');
class MembersSubscriptionCreatedEventsImporter extends TableImporter {
constructor(knex, {subscriptions}) {
super('members_subscription_created_events', knex);
this.subscriptions = subscriptions;
}
setImportOptions({model}) {
this.model = model;
}
generate() {
const subscription = this.subscriptions.find(s => s.id === this.model.subscription_id);
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;