Added a meetingId and an initial number of votes to the Polls collection

This commit is contained in:
Oleksandr Zhurbenko 2015-07-26 15:12:08 -07:00
parent d48734044a
commit 8a45acef92
2 changed files with 14 additions and 9 deletions

View File

@ -1,15 +1,18 @@
# --------------------------------------------------------------------------------------------
# Private methods on server
# --------------------------------------------------------------------------------------------
@addPollToCollection = (poll, requester_id, users) ->
@addPollToCollection = (poll, requester_id, users, meetingId) ->
#copying all the userids into an array
_users = []
i = 0
while i < users.length
_users.push users[i].user.userid
i++
for user in users
_users.push user.user.userid
#adding the initial number of votes for each answer
for answer in poll.answers
answer.number = 0
#adding all together and inserting into the Polls collection
entry =
poll_info:
"meetingId": meetingId
"poll": poll
"requester": requester_id
"users": _users

View File

@ -336,9 +336,11 @@ class Meteor.RedisPubSub
return
if message.header.name is "poll_started_message"
if Meteor.Meetings.findOne({meetingId: message.payload.meeting_id})?
users = Meteor.Users.find({meetingId: message.payload.meeting_id}, {fields:{"user.userid": 1, _id: 0}} ).fetch()
addPollToCollection message.payload.poll, message.payload.requester_id, users
if message.payload.meeting_id? and message.payload.requester_id? and message.payload.poll?
if Meteor.Meetings.findOne({meetingId: message.payload.meeting_id})?
#initializing the list of current users
users = Meteor.Users.find({meetingId: message.payload.meeting_id}, {fields:{"user.userid": 1, _id: 0}} ).fetch()
addPollToCollection message.payload.poll, message.payload.requester_id, users, message.payload.meeting_id
# --------------------------------------------------------------------------------------------
# Private methods on server