heyitsmass / BayView

The next generation reservation tracking and notification system
https://bayview.dev
MIT License
1 stars 2 forks source link

Mock data patch #80

Closed heyitsmass closed 10 months ago

heyitsmass commented 10 months ago

Description

Update of the current Activity and Events type to support additional events and expansion. A new module has been added random that generates random data associated with the types

Motivation and Context

Currently there exists no way to test implementations or gather mock data - Due to legal limitations we're unable to gather data from the intended endpoint and thus need imitation data.

Screenshot:

N/A

Additional Notes

N/A

Example

import random from '@/lib/random';

const event = random.activity.amusementPark();  // Returns the non-hydrated document 

console.log(event);

/** Output: 

{
  rides: [
    'Haunted Mansion',
    'Ferris Wheel',
    'Log Flume',
    'Water Coaster',
    'Swing Ride',
    'Log Flume'
  ],
  admissionFee: 55.5688647122588,
  openingHours: '00:00:00 - 11:59:59',
  rollerCoasters: [
    'Velocity Vortex',
    'Inferno Insanity',
    'Velocity Vortex',
    'Screaming Serpent',
    'Inferno Insanity',
    'Velocity Vortex'
  ],
  themedAreas: [ 'Dinosaur Discovery Zone', "Pirate's Cove" ],
  waterRides: [ 'Waterfall', 'Waterfall', 'Waterfall', 'River Rapids' ],
  heightRestrictions: {
    'Swing Ride': 77,
    'Thrill Thunder': 64,
    'Superhero City': 48,
    'Bumper Cars': 58,
    'Water Coaster': 59,
    'Log Flume': 56
  },
  name: 'complectus aperiam similique',
  location: {
    street: '52564 Dietrich Ways',
    city: 'Lake Bobbycester',
    state: 'Oklahoma',
    zip: '97750'
  },
  description: 'amplexus vis cito',
  */

const document = new AmusementParkModel(event); // Hydration

await EventModel.insertMany([document]); // Saves into the database

A server action handler has also been implemented to gather hydrated documents that are prepared for the database

import { getRandomEvent } from "@/lib/random/handler";

const event = await getRandomEvent('Waterpark');

console.log(event); 

/** Output
{
  name: 'volaticus aeternus laboriosam',
  location: {
    street: '7452 S High Street',
    city: 'Hansenhaven',
    state: 'South Carolina',
    zip: '15246-2715'
  },
  description: 'angustus dedecor dolores',
  attractions: [
    { name: 'FlowRider', description: 'desparatus utilis auditor' },
    { name: 'Tidal Wave Bay', description: 'appono contabesco minima' },
    { name: 'Water Slides', description: 'crastinus solum curriculum' },
    { name: 'Tidal Wave Bay', description: 'claro adulatio tepidus' }
  ],
  waterSlides: [
    { name: 'Rocket Racer', description: 'claro voluptate via' },
    {
      name: 'Twisted Tornado',
      description: 'commodo adinventitias strenuus'
    }
  ],
  openingHours: '03:28:53 - 16:12:33',
  admissionFee: 45.456724458606914,
  wavePool: false,
  lazyRiver: true,
  _id: new ObjectId("6552262e385ef14b29635bd5"),
  __t: 'Waterpark'
}
*/ 

await EventModel.insertMany([event]); // Saves into the database

Types of changes

Checklist:

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bay-view ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 14, 2023 4:26am