|
|
@@ -1,18 +1,18 @@
|
|
1
|
1
|
import Joi from 'joi'
|
|
|
2
|
+import { Connector } from './db.js'
|
|
|
3
|
+import { SurveyFactory } from './survey.js'
|
|
|
4
|
+import { possible } from './lang.js'
|
|
|
5
|
+import { pidMixin, cardMixin } from './mixins.js'
|
|
2
|
6
|
|
|
3
|
|
-import { Connector } from './db'
|
|
4
|
|
-import { SurveyFactory } from './survey'
|
|
5
|
|
-import { possible } from './lang'
|
|
6
|
|
-import { pidMixin, cardMixin } from './mixins'
|
|
7
|
|
-
|
|
8
|
|
-import { possibleZipcodes } from '../../../backend/db/data-generator/config.json'
|
|
|
7
|
+import config from '../../../backend/db/data-generator/config.json' assert { type: 'json' }
|
|
|
8
|
+const possibleZipcodes = config.possibleZipcodes
|
|
9
|
9
|
|
|
10
|
10
|
const api = new Connector('kittens')
|
|
11
|
11
|
|
|
12
|
12
|
const validatorMapping = {
|
|
13
|
13
|
'input-string': Joi.string(),
|
|
14
|
14
|
'tag-cloud': Joi.string(),
|
|
15
|
|
- 'checklist': Joi.string(),
|
|
|
15
|
+ checklist: Joi.string(),
|
|
16
|
16
|
'input-slide': Joi.string(),
|
|
17
|
17
|
}
|
|
18
|
18
|
|
|
|
@@ -22,10 +22,8 @@ const makeKebob = input => {
|
|
22
|
22
|
|
|
23
|
23
|
const surveyFactory = new SurveyFactory(possible['usa'])
|
|
24
|
24
|
|
|
25
|
|
-
|
|
26
|
25
|
const mixins = { pidMixin, cardMixin }
|
|
27
|
26
|
|
|
28
|
|
-
|
|
29
|
27
|
const randomNumber = max => {
|
|
30
|
28
|
return Math.floor(Math.random() * max) < 1
|
|
31
|
29
|
? 1
|
|
|
@@ -75,26 +73,37 @@ const randomMedia = () => {
|
|
75
|
73
|
|
|
76
|
74
|
const randomSurveyResponses = count => {
|
|
77
|
75
|
const surveyResponses = [
|
|
78
|
|
- { id: null, "idOrPrompt": "email", "val": `${randomEmail()}` },
|
|
79
|
|
- { id: null, "idOrPrompt": "name", "val": `john test-${count}` },
|
|
80
|
|
- { id: 99, "idOrPrompt": 15, "val": randomValFrom(possible.usa.pronouns) },
|
|
81
|
|
- { id: null, "idOrPrompt": "seeking", "val": Math.random() > 0.2 ? possible.usa.seeking[0] : possible.usa.seeking[1] },
|
|
82
|
|
- { id: 99, "idOrPrompt": 13, "val": randomValFrom(possible.usa.urgency) },
|
|
83
|
|
- { id: null, "idOrPrompt": "experience", "val": randomValFrom(possible.usa.experience) },
|
|
84
|
|
- { id: 99, "idOrPrompt": 14, "val": "swe" },
|
|
85
|
|
- { id: 99, "idOrPrompt": 10, "val": randomValFrom(possible.usa.duration) },
|
|
86
|
|
- { id: 99, "idOrPrompt": 9, "val": randomValFrom(possible.usa.language) },
|
|
87
|
|
- { id: 99, "idOrPrompt": 11, "val": randomValFrom(possible.usa.presence) },
|
|
88
|
|
- { id: 99, "idOrPrompt": 7, "val": `${randomValFrom(possibleZipcodes)}` },
|
|
89
|
|
- { id: 99, "idOrPrompt": 16, "val": `${randomNumber(55)}` },
|
|
90
|
|
- { id: 99, "idOrPrompt": 12, "val": "this is a test of the survey signup" },
|
|
91
|
|
- { id: 99, "idOrPrompt": 8, "val": randomMedia() },
|
|
92
|
|
- { id: 99, "idOrPrompt": 1, "val": `${randomNumber(3) - randomNumber(3)}` },
|
|
93
|
|
- { id: 99, "idOrPrompt": 2, "val": `${randomNumber(3) - randomNumber(3)}` },
|
|
94
|
|
- { id: 99, "idOrPrompt": 3, "val": `${randomNumber(3) - randomNumber(3)}` },
|
|
95
|
|
- { id: 99, "idOrPrompt": 4, "val": `${randomNumber(3) - randomNumber(3)}` },
|
|
96
|
|
- { id: 99, "idOrPrompt": 5, "val": `${randomNumber(3) - randomNumber(3)}` },
|
|
97
|
|
- { id: 99, "idOrPrompt": 6, "val": `${randomNumber(3) - randomNumber(3)}` }
|
|
|
76
|
+ { id: null, idOrPrompt: 'email', val: `${randomEmail()}` },
|
|
|
77
|
+ { id: null, idOrPrompt: 'name', val: `john test-${count}` },
|
|
|
78
|
+ { id: 99, idOrPrompt: 15, val: randomValFrom(possible.usa.pronouns) },
|
|
|
79
|
+ {
|
|
|
80
|
+ id: null,
|
|
|
81
|
+ idOrPrompt: 'seeking',
|
|
|
82
|
+ val:
|
|
|
83
|
+ Math.random() > 0.2
|
|
|
84
|
+ ? possible.usa.seeking[0]
|
|
|
85
|
+ : possible.usa.seeking[1],
|
|
|
86
|
+ },
|
|
|
87
|
+ { id: 99, idOrPrompt: 13, val: randomValFrom(possible.usa.urgency) },
|
|
|
88
|
+ {
|
|
|
89
|
+ id: null,
|
|
|
90
|
+ idOrPrompt: 'experience',
|
|
|
91
|
+ val: randomValFrom(possible.usa.experience),
|
|
|
92
|
+ },
|
|
|
93
|
+ { id: 99, idOrPrompt: 14, val: 'swe' },
|
|
|
94
|
+ { id: 99, idOrPrompt: 10, val: randomValFrom(possible.usa.duration) },
|
|
|
95
|
+ { id: 99, idOrPrompt: 9, val: randomValFrom(possible.usa.language) },
|
|
|
96
|
+ { id: 99, idOrPrompt: 11, val: randomValFrom(possible.usa.presence) },
|
|
|
97
|
+ { id: 99, idOrPrompt: 7, val: `${randomValFrom(possibleZipcodes)}` },
|
|
|
98
|
+ { id: 99, idOrPrompt: 16, val: `${randomNumber(55)}` },
|
|
|
99
|
+ { id: 99, idOrPrompt: 12, val: 'this is a test of the survey signup' },
|
|
|
100
|
+ { id: 99, idOrPrompt: 8, val: randomMedia() },
|
|
|
101
|
+ { id: 99, idOrPrompt: 1, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
|
102
|
+ { id: 99, idOrPrompt: 2, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
|
103
|
+ { id: 99, idOrPrompt: 3, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
|
104
|
+ { id: 99, idOrPrompt: 4, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
|
105
|
+ { id: 99, idOrPrompt: 5, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
|
106
|
+ { id: 99, idOrPrompt: 6, val: `${randomNumber(3) - randomNumber(3)}` },
|
|
98
|
107
|
]
|
|
99
|
108
|
return surveyResponses
|
|
100
|
109
|
}
|
|
|
@@ -110,5 +119,5 @@ export {
|
|
110
|
119
|
randomValFrom,
|
|
111
|
120
|
randomMedia,
|
|
112
|
121
|
randomName,
|
|
113
|
|
- randomEmail
|
|
|
122
|
+ randomEmail,
|
|
114
|
123
|
}
|