-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate Fake Posts.txt
34 lines (28 loc) · 1.3 KB
/
Create Fake Posts.txt
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
34
const createFakePosts = function(user, amountOfPosts) {
function generateContent() {
if(getRandom(0, 100) > 50) {
let index = getRandom(0, fakePosts.hardcodedPosts.length -1)
var content = fakePosts.hardcodedPosts[index];
} else {
let index = getRandom(0, fakePosts.lorems.length -1)
var content = fakePosts.lorems[index];
}
return content;
}
function minutesAgo(n) {
let date = new Date();
date.setMinutes(date.getMinutes() - n);
return date;
}
let themes = ["primary", "info", "success", "warning", "danger", "purple", "pink", "orange"];
let posts = [];
for(let i = 0; i < amountOfPosts; i++) {
let post = new Post();
post.date = minutesAgo(getRandom(1, 2500));
post.content = generateContent();
post.theme = themes[getRandom(0, themes.length - 1)];
posts.push(post);
}
user.posts.push(...posts);
return user;
}