Improvements to set all endedOn/leftOn when meeting is ended

This commit is contained in:
Gustavo Trott 2021-08-04 16:25:22 -03:00
parent 8346f1d9cf
commit fd4761374f

View File

@ -338,15 +338,29 @@ class ActivityTrackerActor(
for { for {
meeting <- meetings.values.find(m => m.intId == msg.body.meetingId) meeting <- meetings.values.find(m => m.intId == msg.body.meetingId)
} yield { } yield {
//Update endedOn and screenshares.stoppedOn, user.totalTime talks, webcams.stoppedOn
//Update endedOn
val endedOn : Long = System.currentTimeMillis() val endedOn : Long = System.currentTimeMillis()
var updatedMeeting = meeting.copy(endedOn = endedOn) val updatedMeeting = meeting.copy(
endedOn = endedOn,
//Set all users leftOn screenshares = meeting.screenshares.map(screenshare => {
updatedMeeting.users.values.filter(u => u.leftOn == 0).map(user => { if(screenshare.stoppedOn > 0) screenshare;
updatedMeeting = updatedMeeting.copy(users = updatedMeeting.users + (user.intId -> user.copy(leftOn = endedOn))) else screenshare.copy(stoppedOn = endedOn)
}),
users = meeting.users.map(user => {
(user._1 ->
user._2.copy(
leftOn = if(user._2.leftOn > 0) user._2.leftOn else endedOn,
talk = user._2.talk.copy(
totalTime = user._2.talk.totalTime + (if (user._2.talk.lastTalkStartedOn > 0) (endedOn - user._2.talk.lastTalkStartedOn) else 0),
lastTalkStartedOn = 0
),
webcams = user._2.webcams.map(webcam => {
if(webcam.stoppedOn > 0) webcam
else webcam.copy(stoppedOn = endedOn)
}) })
))
})
)
meetings += (updatedMeeting.intId -> updatedMeeting) meetings += (updatedMeeting.intId -> updatedMeeting)