Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
🐛 Make location and offer seeder create correct demo data
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasrohmer committed Oct 25, 2021
1 parent c77b5c7 commit bba5644
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions database/factories/Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
LocationTranslation,
OpeningHours,
Accessibility,
Service,
} from 'App/Models/Location';
import { AddressFactory } from './Address';
import { LinkFactory } from './Link';
Expand Down Expand Up @@ -59,6 +60,11 @@ export const LocationFactory = Factory.define(Location, ({ faker }) => {
return {};
}).build()
)
.relation('service', () =>
Factory.define(Service, ({ faker }) => {
return {};
}).build()
)
.relation('openingHours', () =>
Factory.define(OpeningHours, ({ faker }) => {
const hours = [
Expand Down
6 changes: 6 additions & 0 deletions database/factories/Offer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Factory from '@ioc:Adonis/Lucid/Factory';
import Offer, { OfferTranslation, OfferStatus } from 'App/Models/Offer/Offer';
import OfferDate, { OfferDateTranslation } from 'App/Models/Offer/OfferDate';
import { Audience } from 'App/Models/Offer';
import { LinkFactory } from './Link';
import { DateTime } from 'luxon';
import { MediaFactory } from './Media';
Expand Down Expand Up @@ -107,6 +108,11 @@ export const OfferFactory = Factory.define(Offer, ({ faker }) => {
)
.build()
)
.relation('audience', () =>
Factory.define(Audience, ({ faker }) => {
return {};
}).build()
)
.relation('links', () => LinkFactory)
.relation('media', () => MediaFactory)

Expand Down
1 change: 1 addition & 0 deletions database/seeders/101_Location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export default class LocationSeeder extends BaseSeeder {

factory.with('openingHours', faker.datatype.number(6));
factory.with('accessibility', 1);
factory.with('service', 1);

// if (faker.datatype.boolean()) {
// factory.with('media', faker.datatype.number(1), (mediaFactory) => {
Expand Down
2 changes: 2 additions & 0 deletions database/seeders/102_Offer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export default class OfferSeeder extends BaseSeeder {
}
});

factory.with('audience', 1);

const offer = await factory.create();
await offer.related('organizers').sync([museum.publicId]);
}
Expand Down

0 comments on commit bba5644

Please sign in to comment.