Merge pull request #18954 from gustavotrott/graphql-pres-status-refactor

graphql: refactor presentation props
This commit is contained in:
Gustavo Trott 2023-10-17 11:46:34 -03:00 committed by GitHub
commit e31158d5ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 135 additions and 78 deletions

View File

@ -259,11 +259,12 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
) )
ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", GroupChatMessageType.PRESENTATION, presentationDownloadInfo, "") ChatMessageDAO.insertSystemMsg(liveMeeting.props.meetingProp.intId, GroupChatApp.MAIN_PUBLIC_CHAT, "", GroupChatMessageType.PRESENTATION, presentationDownloadInfo, "")
} else if (m.body.fileStateType == "Converted") { } else if (m.body.fileStateType == "Converted") {
PresPresentationDAO.updatDownloadUri(m.body.presId, m.body.convertedFileURI) PresPresentationDAO.updateDownloadUri(m.body.presId, m.body.convertedFileURI)
} else if (m.body.fileStateType == "Original") { } else if (m.body.fileStateType == "Original") {
PresPresentationDAO.updatDownloadUri(m.body.presId, m.body.originalFileURI) PresPresentationDAO.updateDownloadUri(m.body.presId, m.body.originalFileURI)
} }
PresPresentationDAO.updateExportToChatStatus(m.body.presId, "EXPORTED")
bus.outGW.send(buildBroadcastNewPresFileAvailable(m, liveMeeting)) bus.outGW.send(buildBroadcastNewPresFileAvailable(m, liveMeeting))
} }
@ -279,6 +280,7 @@ trait MakePresentationDownloadReqMsgHdlr extends RightsManagementTrait {
} }
def handle(m: PresAnnStatusMsg, liveMeeting: LiveMeeting, bus: MessageBus): Unit = { def handle(m: PresAnnStatusMsg, liveMeeting: LiveMeeting, bus: MessageBus): Unit = {
PresPresentationDAO.updateExportToChat(m.body.presId, m.body.status, m.body.pageNumber, m.body.error)
bus.outGW.send(buildBroadcastPresAnnStatusMsg(m, liveMeeting)) bus.outGW.send(buildBroadcastPresAnnStatusMsg(m, liveMeeting))
} }

View File

@ -1,9 +1,8 @@
package org.bigbluebutton.core.db package org.bigbluebutton.core.db
import org.bigbluebutton.core.models.{ PresentationInPod, PresentationPage } import org.bigbluebutton.core.models.{ PresentationInPod, PresentationPage }
import PostgresProfile.api._
import org.bigbluebutton.core.models.PresentationInPod import spray.json.JsValue
import slick.jdbc.PostgresProfile.api._
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{ Failure, Success } import scala.util.{ Failure, Success }
@ -12,7 +11,7 @@ case class PresPageDbModel(
pageId: String, pageId: String,
presentationId: String, presentationId: String,
num: Int, num: Int,
urls: String, urlsJson: JsValue,
content: String, content: String,
slideRevealed: Boolean, slideRevealed: Boolean,
current: Boolean, current: Boolean,
@ -26,14 +25,14 @@ case class PresPageDbModel(
viewBoxHeight: Double, viewBoxHeight: Double,
maxImageWidth: Int, maxImageWidth: Int,
maxImageHeight: Int, maxImageHeight: Int,
converted: Boolean uploadCompleted: Boolean
) )
class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pres_page") { class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pres_page") {
val pageId = column[String]("pageId", O.PrimaryKey) val pageId = column[String]("pageId", O.PrimaryKey)
val presentationId = column[String]("presentationId") val presentationId = column[String]("presentationId")
val num = column[Int]("num") val num = column[Int]("num")
val urls = column[String]("urls") val urlsJson = column[JsValue]("urlsJson")
val content = column[String]("content") val content = column[String]("content")
val slideRevealed = column[Boolean]("slideRevealed") val slideRevealed = column[Boolean]("slideRevealed")
val current = column[Boolean]("current") val current = column[Boolean]("current")
@ -47,9 +46,9 @@ class PresPageDbTableDef(tag: Tag) extends Table[PresPageDbModel](tag, None, "pr
val viewBoxHeight = column[Double]("viewBoxHeight") val viewBoxHeight = column[Double]("viewBoxHeight")
val maxImageWidth = column[Int]("maxImageWidth") val maxImageWidth = column[Int]("maxImageWidth")
val maxImageHeight = column[Int]("maxImageHeight") val maxImageHeight = column[Int]("maxImageHeight")
val converted = column[Boolean]("converted") val uploadCompleted = column[Boolean]("uploadCompleted")
// val presentation = foreignKey("presentation_fk", presentationId, Presentations)(_.presentationId, onDelete = ForeignKeyAction.Cascade) // val presentation = foreignKey("presentation_fk", presentationId, Presentations)(_.presentationId, onDelete = ForeignKeyAction.Cascade)
def * = (pageId, presentationId, num, urls, content, slideRevealed, current, xOffset, yOffset, widthRatio, heightRatio, width, height, viewBoxWidth, viewBoxHeight, maxImageWidth, maxImageHeight, converted) <> (PresPageDbModel.tupled, PresPageDbModel.unapply) def * = (pageId, presentationId, num, urlsJson, content, slideRevealed, current, xOffset, yOffset, widthRatio, heightRatio, width, height, viewBoxWidth, viewBoxHeight, maxImageWidth, maxImageHeight, uploadCompleted) <> (PresPageDbModel.tupled, PresPageDbModel.unapply)
} }
object PresPageDAO { object PresPageDAO {

View File

@ -1,6 +1,6 @@
package org.bigbluebutton.core.db package org.bigbluebutton.core.db
import slick.jdbc.PostgresProfile.api._ import PostgresProfile.api._
import org.bigbluebutton.core.models.{ PresentationInPod } import org.bigbluebutton.core.models.{ PresentationInPod }
import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.ExecutionContext.Implicits.global
@ -18,10 +18,14 @@ case class PresPresentationDbModel(
downloadFileExtension: Option[String], downloadFileExtension: Option[String],
downloadFileUri: Option[String], downloadFileUri: Option[String],
removable: Boolean, removable: Boolean,
uploadInProgress: Boolean,
uploadCompleted: Boolean, uploadCompleted: Boolean,
numPages: Int, uploadErrorMsgKey: String,
errorMsgKey: String, uploadErrorDetailsJson: JsValue,
errorDetails: String totalPages: Int,
exportToChatStatus: Option[String],
exportToChatCurrentPage: Option[Int],
exportToChatHasError: Option[Boolean]
) )
class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel](tag, None, "pres_presentation") { class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel](tag, None, "pres_presentation") {
@ -35,14 +39,21 @@ class PresPresentationDbTableDef(tag: Tag) extends Table[PresPresentationDbModel
val downloadFileExtension = column[Option[String]]("downloadFileExtension") val downloadFileExtension = column[Option[String]]("downloadFileExtension")
val downloadFileUri = column[Option[String]]("downloadFileUri") val downloadFileUri = column[Option[String]]("downloadFileUri")
val removable = column[Boolean]("removable") val removable = column[Boolean]("removable")
val uploadInProgress = column[Boolean]("uploadInProgress")
val uploadCompleted = column[Boolean]("uploadCompleted") val uploadCompleted = column[Boolean]("uploadCompleted")
val numPages = column[Int]("numPages") val uploadErrorMsgKey = column[String]("uploadErrorMsgKey")
val errorMsgKey = column[String]("errorMsgKey") val uploadErrorDetailsJson = column[JsValue]("uploadErrorDetailsJson")
val errorDetails = column[String]("errorDetails") val totalPages = column[Int]("totalPages")
val exportToChatStatus = column[Option[String]]("exportToChatStatus")
val exportToChatCurrentPage = column[Option[Int]]("exportToChatCurrentPage")
val exportToChatHasError = column[Option[Boolean]]("exportToChatHasError")
// val meeting = foreignKey("meeting_fk", meetingId, Meetings)(_.meetingId, onDelete = ForeignKeyAction.Cascade) // val meeting = foreignKey("meeting_fk", meetingId, Meetings)(_.meetingId, onDelete = ForeignKeyAction.Cascade)
def * = ( def * = (
presentationId, meetingId, name, filenameConverted, isDefault, current, downloadable, downloadFileExtension, downloadFileUri, removable, uploadCompleted, numPages, errorMsgKey, errorDetails presentationId, meetingId, name, filenameConverted, isDefault, current, downloadable, downloadFileExtension, downloadFileUri, removable,
uploadInProgress, uploadCompleted, uploadErrorMsgKey, uploadErrorDetailsJson, totalPages,
exportToChatStatus, exportToChatCurrentPage, exportToChatHasError
) <> (PresPresentationDbModel.tupled, PresPresentationDbModel.unapply) ) <> (PresPresentationDbModel.tupled, PresPresentationDbModel.unapply)
} }
@ -70,10 +81,14 @@ object PresPresentationDAO {
}, },
downloadFileUri = None, downloadFileUri = None,
removable = presentation.removable, removable = presentation.removable,
uploadInProgress = !presentation.uploadCompleted,
uploadCompleted = presentation.uploadCompleted, uploadCompleted = presentation.uploadCompleted,
numPages = presentation.numPages, totalPages = presentation.numPages,
errorMsgKey = presentation.errorMsgKey, uploadErrorMsgKey = presentation.errorMsgKey,
errorDetails = presentation.errorDetails.toJson.asJsObject.compactPrint uploadErrorDetailsJson = presentation.errorDetails.toJson,
exportToChatStatus = None,
exportToChatCurrentPage = None,
exportToChatHasError = None,
) )
) )
).onComplete { ).onComplete {
@ -89,7 +104,7 @@ object PresPresentationDAO {
pageId = page._2.id, pageId = page._2.id,
presentationId = presentation.id, presentationId = presentation.id,
num = page._2.num, num = page._2.num,
urls = page._2.urls.toJson.asJsObject.compactPrint, urlsJson = page._2.urls.toJson,
content = "Slide Content TODO", //TODO Get content from slide.txtUri (bbb-web should send its content) content = "Slide Content TODO", //TODO Get content from slide.txtUri (bbb-web should send its content)
slideRevealed = page._2.current, slideRevealed = page._2.current,
current = page._2.current, current = page._2.current,
@ -103,7 +118,7 @@ object PresPresentationDAO {
viewBoxHeight = 1, viewBoxHeight = 1,
maxImageWidth = 1440, maxImageWidth = 1440,
maxImageHeight = 1080, maxImageHeight = 1080,
converted = page._2.converted uploadCompleted = page._2.converted
) )
) )
} }
@ -133,7 +148,7 @@ object PresPresentationDAO {
} }
} }
def updatDownloadUri(presentationId: String, downloadFileUri: String) = { def updateDownloadUri(presentationId: String, downloadFileUri: String) = {
DatabaseConnection.db.run( DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef] TableQuery[PresPresentationDbTableDef]
.filter(_.presentationId === presentationId) .filter(_.presentationId === presentationId)
@ -149,14 +164,38 @@ object PresPresentationDAO {
DatabaseConnection.db.run( DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef] TableQuery[PresPresentationDbTableDef]
.filter(_.presentationId === presentationId) .filter(_.presentationId === presentationId)
.map(p => (p.errorMsgKey, p.errorDetails)) .map(p => (p.uploadErrorMsgKey, p.uploadErrorDetailsJson))
.update(errorMsgKey, errorDetails.toJson.asJsObject.compactPrint) .update(errorMsgKey, errorDetails.toJson)
).onComplete { ).onComplete {
case Success(rowAffected) => DatabaseConnection.logger.debug(s"$rowAffected row(s) updated errorMsgKey on PresPresentation table") case Success(rowAffected) => DatabaseConnection.logger.debug(s"$rowAffected row(s) updated errorMsgKey on PresPresentation table")
case Failure(e) => DatabaseConnection.logger.error(s"Error updating errorMsgKey on PresPresentation: $e") case Failure(e) => DatabaseConnection.logger.error(s"Error updating errorMsgKey on PresPresentation: $e")
} }
} }
def updateExportToChat(presentationId: String, exportToChatStatus: String, exportToChatCurrentPage: Int, exportToChatHasError: Boolean) = {
DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef]
.filter(_.presentationId === presentationId)
.map(p => (p.exportToChatStatus, p.exportToChatCurrentPage, p.exportToChatHasError))
.update(Some(exportToChatStatus), Some(exportToChatCurrentPage), Some(exportToChatHasError))
).onComplete {
case Success(rowAffected) => DatabaseConnection.logger.debug(s"$rowAffected row(s) updated exportToChat on PresPresentation table")
case Failure(e) => DatabaseConnection.logger.error(s"Error updating exportToChat on PresPresentation: $e")
}
}
def updateExportToChatStatus(presentationId: String, exportToChatStatus: String) = {
DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef]
.filter(_.presentationId === presentationId)
.map(p => p.exportToChatStatus)
.update(Some(exportToChatStatus))
).onComplete {
case Success(rowAffected) => DatabaseConnection.logger.debug(s"$rowAffected row(s) updated exportToChatStatus on PresPresentation table")
case Failure(e) => DatabaseConnection.logger.error(s"Error updating exportToChatStatus on PresPresentation: $e")
}
}
def delete(presentationId: String) = { def delete(presentationId: String) = {
DatabaseConnection.db.run( DatabaseConnection.db.run(
TableQuery[PresPresentationDbTableDef] TableQuery[PresPresentationDbTableDef]

View File

@ -869,15 +869,18 @@ CREATE TABLE "pres_presentation" (
"filenameConverted" varchar(500), "filenameConverted" varchar(500),
"isDefault" boolean, "isDefault" boolean,
"current" boolean, "current" boolean,
"removable" boolean,
"downloadable" boolean, "downloadable" boolean,
"downloadFileExtension" varchar(25), "downloadFileExtension" varchar(25),
"downloadFileUri" varchar(500), "downloadFileUri" varchar(500),
"removable" boolean, "uploadInProgress" boolean,
"converting" boolean,
"uploadCompleted" boolean, "uploadCompleted" boolean,
"numPages" integer, "uploadErrorMsgKey" varchar(100),
"errorMsgKey" varchar(100), "uploadErrorDetailsJson" jsonb,
"errorDetails" TEXT "totalPages" integer,
"exportToChatStatus" varchar(25),
"exportToChatCurrentPage" integer,
"exportToChatHasError" boolean
); );
CREATE INDEX "idx_pres_presentation_meetingId" ON "pres_presentation"("meetingId"); CREATE INDEX "idx_pres_presentation_meetingId" ON "pres_presentation"("meetingId");
CREATE INDEX "idx_pres_presentation_meetingId_curr" ON "pres_presentation"("meetingId") where "current" is true; CREATE INDEX "idx_pres_presentation_meetingId_curr" ON "pres_presentation"("meetingId") where "current" is true;
@ -886,7 +889,7 @@ CREATE TABLE "pres_page" (
"pageId" varchar(100) PRIMARY KEY, "pageId" varchar(100) PRIMARY KEY,
"presentationId" varchar(100) REFERENCES "pres_presentation"("presentationId") ON DELETE CASCADE, "presentationId" varchar(100) REFERENCES "pres_presentation"("presentationId") ON DELETE CASCADE,
"num" integer, "num" integer,
"urls" TEXT, "urlsJson" jsonb,
"content" TEXT, "content" TEXT,
"slideRevealed" boolean default false, "slideRevealed" boolean default false,
"current" boolean, "current" boolean,
@ -900,7 +903,7 @@ CREATE TABLE "pres_page" (
"viewBoxHeight" NUMERIC, "viewBoxHeight" NUMERIC,
"maxImageWidth" integer, "maxImageWidth" integer,
"maxImageHeight" integer, "maxImageHeight" integer,
"converted" boolean "uploadCompleted" boolean
); );
CREATE INDEX "idx_pres_page_presentationId" ON "pres_page"("presentationId"); CREATE INDEX "idx_pres_page_presentationId" ON "pres_page"("presentationId");
CREATE INDEX "idx_pres_page_presentationId_curr" ON "pres_page"("presentationId") where "current" is true; CREATE INDEX "idx_pres_page_presentationId_curr" ON "pres_page"("presentationId") where "current" is true;
@ -916,12 +919,23 @@ SELECT pres_presentation."meetingId",
pres_presentation."downloadFileExtension", pres_presentation."downloadFileExtension",
pres_presentation."downloadFileUri", pres_presentation."downloadFileUri",
pres_presentation."removable", pres_presentation."removable",
pres_presentation."converting", pres_presentation."uploadInProgress",
pres_presentation."uploadCompleted", pres_presentation."uploadCompleted",
pres_presentation."numPages", pres_presentation."totalPages",
pres_presentation."errorMsgKey", ( SELECT count(*)
pres_presentation."errorDetails", FROM pres_page
(SELECT count(*) FROM pres_page WHERE pres_page."presentationId" = pres_presentation."presentationId" AND "converted" is true) as "pagesUploaded" WHERE pres_page."presentationId" = pres_presentation."presentationId"
AND "uploadCompleted" is true
) as "totalPagesUploaded",
pres_presentation."uploadErrorMsgKey",
pres_presentation."uploadErrorDetailsJson",
case when pres_presentation."exportToChatStatus" is not null
and pres_presentation."exportToChatStatus" != 'EXPORTED'
and pres_presentation."exportToChatHasError" is not true
then true else false end "exportToChatInProgress",
pres_presentation."exportToChatStatus",
pres_presentation."exportToChatCurrentPage",
pres_presentation."exportToChatHasError"
FROM pres_presentation; FROM pres_presentation;
CREATE OR REPLACE VIEW public.v_pres_page AS CREATE OR REPLACE VIEW public.v_pres_page AS
@ -929,7 +943,7 @@ SELECT pres_presentation."meetingId",
pres_page."presentationId", pres_page."presentationId",
pres_page."pageId", pres_page."pageId",
pres_page.num, pres_page.num,
pres_page.urls, pres_page."urlsJson",
pres_page.content, pres_page.content,
pres_page."slideRevealed", pres_page."slideRevealed",
CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage", CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage",
@ -945,7 +959,7 @@ SELECT pres_presentation."meetingId",
(pres_page."height" * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledHeight", (pres_page."height" * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledHeight",
(pres_page."width" * pres_page."widthRatio" / 100 * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledViewBoxWidth", (pres_page."width" * pres_page."widthRatio" / 100 * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledViewBoxWidth",
(pres_page."height" * pres_page."heightRatio" / 100 * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledViewBoxHeight", (pres_page."height" * pres_page."heightRatio" / 100 * LEAST(pres_page."maxImageWidth" / pres_page."width", pres_page."maxImageHeight" / pres_page."height")) AS "scaledViewBoxHeight",
pres_page."converted" pres_page."uploadCompleted"
FROM pres_page FROM pres_page
JOIN pres_presentation ON pres_presentation."presentationId" = pres_page."presentationId"; JOIN pres_presentation ON pres_presentation."presentationId" = pres_page."presentationId";
@ -960,9 +974,9 @@ SELECT pres_presentation."meetingId",
case when pres_presentation."downloadable" then pres_presentation."downloadFileExtension" else null end "downloadFileExtension", case when pres_presentation."downloadable" then pres_presentation."downloadFileExtension" else null end "downloadFileExtension",
case when pres_presentation."downloadable" then pres_presentation."downloadFileUri" else null end "downloadFileUri", case when pres_presentation."downloadable" then pres_presentation."downloadFileUri" else null end "downloadFileUri",
pres_presentation."removable", pres_presentation."removable",
pres_presentation."numPages", pres_presentation."totalPages",
pres_page.num, pres_page.num,
pres_page.urls, pres_page."urlsJson",
pres_page.content, pres_page.content,
pres_page."slideRevealed", pres_page."slideRevealed",
CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage", CASE WHEN pres_presentation."current" IS TRUE AND pres_page."current" IS TRUE THEN true ELSE false END AS "isCurrentPage",

View File

@ -32,7 +32,7 @@ select_permissions:
- scaledViewBoxWidth - scaledViewBoxWidth
- scaledWidth - scaledWidth
- slideRevealed - slideRevealed
- urls - urlsJson
- viewBoxHeight - viewBoxHeight
- viewBoxWidth - viewBoxWidth
- width - width

View File

@ -19,7 +19,7 @@ select_permissions:
- isCurrentPage - isCurrentPage
- isDefaultPresentation - isDefaultPresentation
- num - num
- numPages - totalPages
- pageId - pageId
- presentationFilenameConverted - presentationFilenameConverted
- presentationId - presentationId
@ -30,7 +30,7 @@ select_permissions:
- scaledViewBoxWidth - scaledViewBoxWidth
- scaledWidth - scaledWidth
- slideRevealed - slideRevealed
- urls - urlsJson
- viewBoxHeight - viewBoxHeight
- viewBoxWidth - viewBoxWidth
- width - width

View File

@ -20,21 +20,24 @@ select_permissions:
- role: bbb_client - role: bbb_client
permission: permission:
columns: columns:
- converting
- current - current
- downloadFileUri - downloadFileUri
- downloadable - downloadable
- downloadFileExtension - downloadFileExtension
- errorDetails - uploadInProgress
- errorMsgKey - uploadCompleted
- uploadErrorMsgKey
- uploadErrorDetailsJson
- exportToChatStatus
- exportToChatCurrentPage
- exportToChatHasError
- filenameConverted - filenameConverted
- isDefault - isDefault
- name - name
- numPages - totalPages
- pagesUploaded - totalPagesUploaded
- presentationId - presentationId
- removable - removable
- uploadCompleted
filter: filter:
meetingId: meetingId:
_eq: X-Hasura-PresenterInMeeting _eq: X-Hasura-PresenterInMeeting