mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
28b11e6fed
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`
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
const TableImporter = require('./base');
|
|
const {faker} = require('@faker-js/faker');
|
|
|
|
class MembersPaidSubscriptionEventsImporter extends TableImporter {
|
|
constructor(knex, {membersStripeCustomersSubscriptions}) {
|
|
super('members_paid_subscription_events', knex);
|
|
this.membersStripeCustomersSubscriptions = membersStripeCustomersSubscriptions;
|
|
}
|
|
|
|
setImportOptions({model}) {
|
|
this.model = model;
|
|
}
|
|
|
|
generate() {
|
|
if (!this.model.currency) {
|
|
// Not a paid subscription
|
|
return null;
|
|
}
|
|
// TODO: Implement upgrades
|
|
const membersStripeCustomersSubscription = this.membersStripeCustomersSubscriptions.find((m) => {
|
|
return m.subscription_id === this.model.id;
|
|
});
|
|
return {
|
|
id: faker.database.mongodbObjectId(),
|
|
// TODO: Support expired / updated / cancelled events too
|
|
type: 'created',
|
|
member_id: this.model.member_id,
|
|
subscription_id: this.model.id,
|
|
from_plan: null,
|
|
to_plan: membersStripeCustomersSubscription.plan_id,
|
|
currency: this.model.currency,
|
|
source: 'stripe',
|
|
mrr_delta: membersStripeCustomersSubscription.mrr,
|
|
created_at: this.model.created_at
|
|
};
|
|
}
|
|
}
|
|
|
|
module.exports = MembersPaidSubscriptionEventsImporter;
|