/
generate-fake-data.js
70 lines (59 loc) · 2.27 KB
/
generate-fake-data.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const faker = require('faker')
function generateData () {
let jobs = []
for (let id = 0; id < 100; id++) {
let technologies = getTechnologies()
let country = getCountry()
let title = getJobTitle()
let companyName = getCompanyName()
let shortParagraph = getShortParagraph(title, companyName)
let datePosted = faker.date.recent()
jobs.push({
id: id,
title: title,
country: country,
datePosted: datePosted,
technologies: technologies,
shortParagraph: shortParagraph,
company: {
name: companyName
}
})
}
return { jobs }
}
function getTechnologies () {
const availableTechnologies = [
{ name: 'Vue.js' }, { name: 'Angular' }, { name: 'Laravel' }, { name: 'Python' }, { name: 'flask' },
{ name: 'Java' }, { name: 'PHP' }, { name: 'Javascript' }]
let numberOfTechnologies = Math.floor((Math.random() * 5) + 1)
return availableTechnologies
.map(x => ({ x, r: Math.random() }))
.sort((a, b) => a.r - b.r)
.map(a => a.x)
.slice(0, numberOfTechnologies)
}
function getJobTitle () {
const availableTitles = ['Software Developer', 'Software Engineer', 'Programmer',
'Front-end developer', 'Back-end developer', 'Software Engineer']
return availableTitles[Math.floor(Math.random() * availableTitles.length)]
}
function getShortParagraph (jobTitle, companyName) {
const availableParagraphs = [
`${companyName} is looking for a talented ${jobTitle} to join the team! `,
`Looking for a ${jobTitle} to join ${companyName} for a great project!`,
`We, at ${companyName} are currently looking for a ${jobTitle} to join us.`,
`Currently trying to find a ${jobTitle} to join our team for a new project.`
]
return availableParagraphs[Math.floor(Math.random() * availableParagraphs.length)]
}
function getCountry () {
const availableCountries = ['USA', 'Greece', 'United Kingdom', 'Germany', 'France']
return availableCountries[Math.floor(Math.random() * availableCountries.length)]
}
function getCompanyName () {
const availableCompanies = ['Some-Company Ltd', 'The Best Insurance Company',
'We Are The Worst Company LLC', 'Another Marketing Company LLP']
return availableCompanies[Math.floor(Math.random() * availableCompanies.length)]
}
module.exports = generateData