From 09807fb99fb8c731a97093e562d726b4d1fd4269 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Thu, 8 Jun 2023 13:46:22 +0200 Subject: [PATCH] seed events --- backend/src/db/seed.js | 74 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) diff --git a/backend/src/db/seed.js b/backend/src/db/seed.js index a8f8b9c68..9eb67abbf 100644 --- a/backend/src/db/seed.js +++ b/backend/src/db/seed.js @@ -596,7 +596,79 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] }), ]) - // Create Posts + // Create Events (by peter lustig) + authenticatedUser = await peterLustig.toJson() + const now = new Date() + + await Promise.all([ + mutate({ + mutation: createPostMutation(), + variables: { + id: 'e0', + title: 'Illegaler Kindergeburtstag', + content: 'Elli hat nächste Woche Geburtstag. Wir feiern das!', + categoryIds: ['cat4'], + postType: 'Event', + eventInput: { + eventStart: new Date( + now.getFullYear(), + now.getMonth(), + now.getDate() + 7, + ).toISOString(), + eventVenue: 'Ellis Kinderzimmer', + eventLocationName: 'Deutschland', + }, + }, + }), + mutate({ + mutation: createPostMutation(), + variables: { + id: 'e1', + title: 'Wir Schützen den Stuttgarter Schlossgarten', + content: 'Kein Baum wird gefällt werden!', + categoryIds: ['cat5'], + postType: 'Event', + eventInput: { + eventStart: new Date( + now.getFullYear(), + now.getMonth(), + now.getDate() + 1, + ).toISOString(), + eventVenue: 'Schlossgarten', + eventLocationName: 'Stuttgart', + }, + }, + }), + mutate({ + mutation: createPostMutation(), + variables: { + id: 'e2', + title: 'IT 4 Change Treffen', + content: 'Wir sitzen eine Woche zusammen rum und glotzen uns blöde an.', + categoryIds: ['cat5'], + postType: 'Event', + eventInput: { + eventStart: new Date( + now.getFullYear(), + now.getMonth(), + now.getDate() + 1, + ).toISOString(), + eventEnd: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 4).toISOString(), + eventVenue: 'Ferienlager', + eventLocationName: 'Bahra, Sachsen', + }, + }, + }), + ]) + + let passedEvent = await neode.find('Post', 'e1') + await passedEvent.update({ eventStart: new Date(2010, 8, 30, 10).toISOString() }) + passedEvent = await neode.find('Post', 'e2') + await passedEvent.update({ + eventStart: new Date(now.getFullYear(), now.getMonth(), now.getDate() - 3).toISOString(), + }) + + // Create Posts (Articles) const [p0, p1, p3, p4, p5, p6, p9, p10, p11, p13, p14, p15] = await Promise.all([ Factory.build(