refactor(seeds): Use buildList to setup lists

This commit is contained in:
roschaefer 2020-01-28 23:30:09 +01:00
parent fc367297e3
commit f9c42ab2a5

View File

@ -933,334 +933,140 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl']
trollingComment.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }), trollingComment.update({ disabled: true, updatedAt: new Date().toISOString(), closed: true }),
]) ])
await Promise.all( await Factory.buildList('user', 30)
[...Array(30).keys()].map(i => {
return Factory.build('user')
}),
)
await Promise.all( await Factory.buildList( 'post', 30, {
[...Array(30).keys()].map(() => { image: faker.image.unsplash.objects(),
return Factory.build( }, {
'post', categoryIds: ['cat1'],
{ author: jennyRostock,
image: faker.image.unsplash.objects(), })
},
{
categoryIds: ['cat1'],
author: jennyRostock,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 6, {}, {
[...Array(6).keys()].map(() => { author: jennyRostock,
return Factory.build( postId: 'p2',
'comment', })
{},
{
author: jennyRostock,
postId: 'p2',
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 4, {}, {
[...Array(4).keys()].map(() => { author: jennyRostock,
return Factory.build( postId: 'p15',
'comment', })
{},
{
author: jennyRostock,
postId: 'p15',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 2, {}, {
[...Array(2).keys()].map(() => { author: jennyRostock,
return Factory.build( postId: 'p4',
'comment', })
{},
{
author: jennyRostock,
postId: 'p4',
},
)
}),
)
await Promise.all( await Factory.buildList('post', 21, {
[...Array(21).keys()].map(() => { image: faker.image.unsplash.buildings(),
return Factory.build( }, {
'post', author: peterLustig,
{ })
image: faker.image.unsplash.buildings(),
},
{
author: peterLustig,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 3, {}, {
[...Array(3).keys()].map(() => { author: peterLustig,
return Factory.build( postId: 'p4',
'comment', })
{},
{
author: peterLustig,
postId: 'p4',
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 5, {}, {
[...Array(5).keys()].map(() => { author: peterLustig,
return Factory.build( postId: 'p14',
'comment', })
{},
{
author: peterLustig,
postId: 'p14',
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 6, {}, {
[...Array(6).keys()].map(() => { author: peterLustig,
return Factory.build( postId: 'p0',
'comment', })
{},
{
author: peterLustig,
postId: 'p0',
},
)
}),
)
await Promise.all( await Factory.buildList( 'post', 11, {
[...Array(11).keys()].map(() => { image: faker.image.unsplash.food(),
return Factory.build( }, {
'post', author: dewey,
{ })
image: faker.image.unsplash.food(),
},
{
author: dewey,
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 7, {}, {
[...Array(7).keys()].map(() => { author: dewey,
return Factory.build( postId: 'p2',
'comment', })
{},
{
author: dewey,
postId: 'p2',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 5, {}, {
[...Array(5).keys()].map(() => { author: dewey,
return Factory.build( postId: 'p6',
'comment', })
{},
{
author: dewey,
postId: 'p6',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 2, {}, {
[...Array(2).keys()].map(() => { author: dewey,
return Factory.build( postId: 'p9',
'comment', })
{},
{
author: dewey,
postId: 'p9',
},
)
}),
)
await Promise.all( await Factory.buildList('post', 16, {
[...Array(16).keys()].map(() => { image: faker.image.unsplash.technology(),
return Factory.build( }, {
'post', author: louie,
{ })
image: faker.image.unsplash.technology(),
},
{
author: louie,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 4, {}, {
[...Array(4).keys()].map(() => { postId: 'p1',
return Factory.build( author: louie,
'comment', })
{},
{
postId: 'p1',
author: louie,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 8, {}, {
[...Array(8).keys()].map(() => { author: louie,
return Factory.build( postId: 'p10',
'comment', })
{},
{
author: louie,
postId: 'p10',
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 5, {}, {
[...Array(5).keys()].map(() => { author: louie,
return Factory.build( postId: 'p13',
'comment', })
{},
{
author: louie,
postId: 'p13',
},
)
}),
)
await Promise.all( await Factory.buildList('post', 45, {
[...Array(45).keys()].map(() => { image: faker.image.unsplash.people(),
return Factory.build( }, {
'post', author: bobDerBaumeister,
{ })
image: faker.image.unsplash.people(),
},
{
author: bobDerBaumeister,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 2, {}, {
[...Array(2).keys()].map(() => { author: bobDerBaumeister,
return Factory.build( postId: 'p2',
'comment', })
{},
{
author: bobDerBaumeister,
postId: 'p2',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 3, {}, {
[...Array(3).keys()].map(() => { author: bobDerBaumeister,
return Factory.build( postId: 'p12',
'comment', })
{},
{
author: bobDerBaumeister,
postId: 'p12',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 7, {}, {
[...Array(7).keys()].map(() => { author: bobDerBaumeister,
return Factory.build( postId: 'p13',
'comment', })
{},
{
author: bobDerBaumeister,
postId: 'p13',
},
)
}),
)
await Promise.all( await Factory.buildList( 'post', 8, {
[...Array(8).keys()].map(() => { image: faker.image.unsplash.nature(),
return Factory.build( }, {
'post', author: huey,
{ })
image: faker.image.unsplash.nature(),
},
{
author: huey,
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 6, {}, {
[...Array(6).keys()].map(() => { author: huey,
return Factory.build( postId: 'p0',
'comment', })
{},
{
author: huey,
postId: 'p0',
},
)
}),
)
await Promise.all( await Factory.buildList( 'comment', 8, {}, {
[...Array(8).keys()].map(() => { author: huey,
return Factory.build( postId: 'p13',
'comment', })
{},
{
author: huey,
postId: 'p13',
},
)
}),
)
await Promise.all( await Factory.buildList('comment', 9, {}, {
[...Array(9).keys()].map(() => { author: huey,
return Factory.build( postId: 'p15',
'comment', })
{},
{
author: huey,
postId: 'p15',
},
)
}),
)
await Factory.build('donations') await Factory.build('donations')
/* eslint-disable-next-line no-console */ /* eslint-disable-next-line no-console */
console.log('Seeded Data...') console.log('Seeded Data...')
await driver.close()
await neode.close()
process.exit(0) process.exit(0)
} catch (err) { } catch (err) {
/* eslint-disable-next-line no-console */ /* eslint-disable-next-line no-console */