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