Data generator: Ensure order of newsletters is correct

no issue
This commit is contained in:
Sam Lord 2023-08-04 13:07:20 +01:00 committed by Sam Lord
parent 4ff467794f
commit 356256067c
4 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ class EmailsImporter extends TableImporter {
async import(quantity) {
const posts = await this.transaction.select('id', 'title', 'published_at').from('posts').where('type', 'post');
this.newsletters = await this.transaction.select('id').from('newsletters');
this.newsletters = await this.transaction.select('id').from('newsletters').orderBy('sort_order');
this.membersSubscribeEvents = await this.transaction.select('id', 'newsletter_id', 'created_at').from('members_subscribe_events');
await this.importForEach(posts, quantity ? quantity / posts.length : 1);

View File

@ -70,7 +70,7 @@ class MembersImporter extends TableImporter {
return {
id,
uuid: faker.datatype.uuid(),
email: faker.internet.email(name, faker.date.birthdate().getFullYear().toString(), 'example.com').toLowerCase(),
email: `${name.replace(' ', '.').replace(/[^a-zA-Z0-9]/g, '').toLowerCase()}${faker.datatype.number({min: 1000, max: 9999})}@example.com`,
status: luck(5) ? 'comped' : luck(25) ? 'paid' : 'free',
name: name,
expertise: luck(30) ? faker.name.jobTitle() : undefined,

View File

@ -13,7 +13,7 @@ class MembersSubscribeEventsImporter extends TableImporter {
async import(quantity) {
const members = await this.transaction.select('id', 'created_at', 'status').from('members');
this.newsletters = await this.transaction.select('id').from('newsletters');
this.newsletters = await this.transaction.select('id').from('newsletters').orderBy('sort_order');
this.subscriptions = await this.transaction.select('member_id', 'created_at').from('subscriptions');
await this.importForEach(members, quantity ? quantity / members.length : 2);

View File

@ -19,7 +19,7 @@ class PostsImporter extends TableImporter {
}
async import(quantity = this.defaultQuantity) {
this.newsletters = await this.transaction.select('id').from('newsletters');
this.newsletters = await this.transaction.select('id').from('newsletters').orderBy('sort_order');
await super.import(quantity);
}