-
Notifications
You must be signed in to change notification settings - Fork 1
/
my-functions.js
33 lines (31 loc) · 1.23 KB
/
my-functions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"use strict";
module.exports = {
generateRandomData
};
const faker = require("faker");
function generateRandomData(Context, events, done) {
const listing_id = Math.floor(Math.random() * 10000000 + 1);
const title = faker.lorem.sentence().slice(0, 5);
const price = Math.floor(Math.random() * 500) + 60;
const homeType = ["Entire place", "Private room", "Shared room"][
Math.floor(Math.random() * 3)
];
const bedsNumber = Math.floor(Math.random() * 3) + 1;
const reviewsAverage =
Math.floor(Math.random() * (5 * 10 - 1 * 10) + 1 * 10) / (1 * 10);
const numberOfReviews = Math.floor(Math.random() * 100) + 1;
const likedStatus = Math.floor(Math.random() * 1 + 0.5);
const plusStatus = Math.floor(Math.random() * 1 + 0.5);
const image1 = `http://airbnb-recommendation-photos.s3-website-us-west-1.amazonaws.com/photo1`;
Context.vars.listing_id = listing_id;
Context.vars.title = title;
Context.vars.price = price;
Context.vars.homeType = homeType;
Context.vars.bedsNumber = bedsNumber;
Context.vars.reviewsAverage = reviewsAverage;
Context.vars.numberOfReviews = numberOfReviews;
Context.vars.likedStatus = likedStatus;
Context.vars.plusStatus = plusStatus;
Context.vars.image1 = image1;
return done();
}