1
1
import mongoose from 'mongoose' ;
2
2
import bluebird from 'bluebird' ;
3
3
import _ from 'lodash' ;
4
- import { User , Poll , Vote } from 'which-types' ;
4
+ import {
5
+ User ,
6
+ Poll ,
7
+ Vote ,
8
+ Feedback
9
+ } from 'which-types' ;
5
10
6
11
import app from './app' ;
7
12
@@ -71,6 +76,13 @@ const createVote = (userId: string, pollId: string): Promise<Vote> => {
71
76
} , { user : { _id : userId } , authenticated : true } ) ;
72
77
} ;
73
78
79
+ const createFeedback = ( userId : string ) : Promise < Feedback > => {
80
+ return app . service ( 'feedback' ) . create ( {
81
+ version : 'v1.0.0' ,
82
+ score : _ . sample ( [ 1 , 2 , 3 , 4 , 5 ] ) ,
83
+ content : 'Absolutely amazing!'
84
+ } , { user : { _id : userId } , authenticated : true } ) ;
85
+ } ;
74
86
75
87
const populate = async ( ) => {
76
88
const users = await bluebird . map ( names , name => createUser ( name ) ) ;
@@ -80,6 +92,10 @@ const populate = async () => {
80
92
return createPoll ( user ?. _id || '' ) ;
81
93
} ) ;
82
94
95
+ await bluebird . map ( users , user => {
96
+ return createFeedback ( user ?. _id || '' ) ;
97
+ } ) ;
98
+
83
99
await bluebird . map ( users , user => {
84
100
const pollsToVote = _ . sampleSize ( polls , _ . random ( 0 , POLLS_AMOUNT ) ) ;
85
101
return bluebird . map ( pollsToVote , poll => createVote ( user ?. _id || '' , poll ?. _id || '' ) ) ;
0 commit comments