graphql: Update meeting duration when breakout duration is updated

This commit is contained in:
Gustavo Trott 2023-10-04 10:28:11 -03:00
parent 31c853f801
commit 5c8bbe6c06
3 changed files with 22 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import org.bigbluebutton.common2.msgs._
import org.bigbluebutton.core.api.{ SendTimeRemainingAuditInternalMsg, UpdateBreakoutRoomTimeInternalMsg }
import org.bigbluebutton.core.apps.{ PermissionCheck, RightsManagementTrait }
import org.bigbluebutton.core.bus.BigBlueButtonEvent
import org.bigbluebutton.core.db.BreakoutRoomDAO
import org.bigbluebutton.core.db.{ BreakoutRoomDAO, MeetingDAO }
import org.bigbluebutton.core.domain.MeetingState2x
import org.bigbluebutton.core.running.{ MeetingActor, OutMsgRouter }
import org.bigbluebutton.core2.message.senders.{ MsgBuilder, Sender }
@ -78,6 +78,7 @@ trait UpdateBreakoutRoomsTimeMsgHdlr extends RightsManagementTrait {
log.debug("Updating {} minutes for breakout rooms time in meeting {}", msg.body.timeInMinutes, props.meetingProp.intId)
BreakoutRoomDAO.updateRoomsDuration(props.meetingProp.intId, newDurationInSeconds)
MeetingDAO.updateMeetingDurationByParentMeeting(props.meetingProp.intId, newDurationInSeconds)
breakoutModel.setTime(newDurationInSeconds)
}
}

View File

@ -175,10 +175,11 @@ object BreakoutRoomDAO {
}
}
def updateRoomsDuration(meetingId: String, newDurationInSeconds: Int) = {
def updateRoomsDuration(parentMeetingId: String, newDurationInSeconds: Int) = {
DatabaseConnection.db.run(
TableQuery[BreakoutRoomDbTableDef]
.filter(_.parentMeetingId === meetingId)
.filter(_.parentMeetingId === parentMeetingId)
.filter(_.endedAt.isEmpty)
.map(u => u.durationInSeconds)
.update(newDurationInSeconds)
).onComplete {

View File

@ -93,6 +93,23 @@ object MeetingDAO {
}
}
def updateMeetingDurationByParentMeeting(parentMeetingId: String, newDurationInSeconds: Int) = {
val subqueryBreakoutRooms = TableQuery[BreakoutRoomDbTableDef]
.filter(_.parentMeetingId === parentMeetingId)
.filter(_.endedAt.isEmpty)
.map(_.externalId)
DatabaseConnection.db.run(
TableQuery[MeetingDbTableDef]
.filter(_.extId in subqueryBreakoutRooms)
.map(u => u.duration)
.update(newDurationInSeconds)
).onComplete {
case Success(rowsAffected) => DatabaseConnection.logger.debug(s"$rowsAffected row(s) updated duration on Meeting table")
case Failure(e) => DatabaseConnection.logger.debug(s"Error updating duration on Meeting: $e")
}
}
def delete(meetingId: String) = {
DatabaseConnection.db.run(
TableQuery[MeetingDbTableDef]