diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-06-28 19:01:52 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-28 19:01:52 +0300 |
commit | 88e97a42096c1e4de7b9f1d8fefa0829bbc0d321 (patch) | |
tree | ae402f77d0d0d7b8d06dcefc614bbb9aad12ed59 /populateDb.ts | |
parent | 8baf96be5ea7880cebe3aeda733b9196950be434 (diff) | |
parent | 29197dd3bc7e941707979b6c226e5f3b1a4cbbed (diff) | |
download | which-api-88e97a42096c1e4de7b9f1d8fefa0829bbc0d321.tar.gz |
Merge pull request #16 from which-ecosystem/feedback
Feedback endpoint & schema updates
Diffstat (limited to 'populateDb.ts')
-rw-r--r-- | populateDb.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/populateDb.ts b/populateDb.ts index b3e46af..e25005d 100644 --- a/populateDb.ts +++ b/populateDb.ts @@ -1,7 +1,12 @@ import mongoose from 'mongoose'; import bluebird from 'bluebird'; import _ from 'lodash'; -import { User, Poll, Vote } from 'which-types'; +import { + User, + Poll, + Vote, + Feedback +} from 'which-types'; import app from './app'; @@ -71,6 +76,13 @@ const createVote = (userId: string, pollId: string): Promise<Vote> => { }, { user: { _id: userId }, authenticated: true }); }; +const createFeedback = (userId: string): Promise<Feedback> => { + return app.service('feedback').create({ + version: 'v1.0.0', + score: _.sample([1, 2, 3, 4, 5]), + content: 'Absolutely amazing!' + }, { user: { _id: userId }, authenticated: true }); +}; const populate = async () => { const users = await bluebird.map(names, name => createUser(name)); @@ -81,6 +93,10 @@ const populate = async () => { }); await bluebird.map(users, user => { + return createFeedback(user?._id || ''); + }); + + await bluebird.map(users, user => { const pollsToVote = _.sampleSize(polls, _.random(0, POLLS_AMOUNT)); return bluebird.map(pollsToVote, poll => createVote(user?._id || '', poll?._id || '')); }); |