Improve insert of annotations to send it in batch
This commit is contained in:
parent
60c15006f2
commit
392953f08e
@ -23,8 +23,11 @@ class PresAnnotationDbTableDef(tag: Tag) extends Table[PresAnnotationDbModel](ta
|
||||
}
|
||||
|
||||
object PresAnnotationDAO {
|
||||
|
||||
def prepareInsertOrUpdate(meetingId: String, annotation: AnnotationVO, annotationUpdatedAt: Long) = {
|
||||
def insertOrUpdateMap(meetingId: String, annotations: Array[AnnotationVO], annotationUpdatedAt: Long) = {
|
||||
for {
|
||||
annotation <- annotations
|
||||
} yield {
|
||||
DatabaseConnection.enqueue(
|
||||
TableQuery[PresAnnotationDbTableDef].insertOrUpdate(
|
||||
PresAnnotationDbModel(
|
||||
annotationId = annotation.id,
|
||||
@ -35,17 +38,9 @@ object PresAnnotationDAO {
|
||||
lastUpdatedAt = new java.sql.Timestamp(annotationUpdatedAt)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
def insertOrUpdateMap(meetingId: String, annotations: Array[AnnotationVO], annotationUpdatedAt: Long) = {
|
||||
DatabaseConnection.enqueue(
|
||||
DBIO.sequence(
|
||||
annotations.map { annotation =>
|
||||
prepareInsertOrUpdate(meetingId, annotation, annotationUpdatedAt)
|
||||
}.toVector
|
||||
).transactionally
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
def deleteAnnotations(meetingId: String, userId: String, annotationIds: Array[String], annotationUpdatedAt: Long) = {
|
||||
DatabaseConnection.enqueue(
|
||||
|
@ -24,24 +24,8 @@ class PresAnnotationHistoryDbTableDef(tag: Tag) extends Table[PresAnnotationHist
|
||||
|
||||
object PresAnnotationHistoryDAO {
|
||||
|
||||
def delete(wbId: String, meetingId: String, userId: String, annotationId: String, annotationUpdatedAt: Long) = {
|
||||
DatabaseConnection.enqueue(
|
||||
TableQuery[PresAnnotationHistoryDbTableDef].forceInsert(
|
||||
PresAnnotationHistoryDbModel(
|
||||
// None,
|
||||
annotationId = annotationId,
|
||||
pageId = wbId,
|
||||
meetingId = meetingId,
|
||||
userId = userId,
|
||||
annotationInfo = "",
|
||||
updatedAt = new java.sql.Timestamp(annotationUpdatedAt)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
def prepareInsertOrUpdate(meetingId: String, annotation: AnnotationVO, annotationUpdatedAt: Long) = {
|
||||
TableQuery[PresAnnotationHistoryDbTableDef].forceInsert(
|
||||
def insertOrUpdateMap(meetingId: String, annotations: Array[AnnotationVO], annotationUpdatedAt: Long) = {
|
||||
val dbModels = annotations.map { annotation =>
|
||||
PresAnnotationHistoryDbModel(
|
||||
annotationId = annotation.id,
|
||||
pageId = annotation.wbId,
|
||||
@ -50,21 +34,14 @@ object PresAnnotationHistoryDAO {
|
||||
annotationInfo = JsonUtils.mapToJson(annotation.annotationInfo).compactPrint,
|
||||
updatedAt = new java.sql.Timestamp(annotationUpdatedAt)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
def insertOrUpdateMap(meetingId: String, annotations: Array[AnnotationVO], annotationUpdatedAt: Long) = {
|
||||
DatabaseConnection.enqueue(
|
||||
DBIO.sequence(
|
||||
annotations.map { annotation =>
|
||||
prepareInsertOrUpdate(meetingId, annotation, annotationUpdatedAt)
|
||||
}.toVector
|
||||
).transactionally
|
||||
TableQuery[PresAnnotationHistoryDbTableDef] ++= dbModels
|
||||
)
|
||||
}
|
||||
|
||||
def prepareDelete(meetingId: String, pageId: String, annotationId: String, userId: String, annotationUpdatedAt: Long) = {
|
||||
TableQuery[PresAnnotationHistoryDbTableDef].forceInsert(
|
||||
def deleteAnnotations(meetingId: String, pageId: String, userId: String, annotations: Array[String], annotationUpdatedAt: Long) = {
|
||||
val dbModels = annotations.map { annotationId =>
|
||||
PresAnnotationHistoryDbModel(
|
||||
annotationId = annotationId,
|
||||
pageId = pageId,
|
||||
@ -73,16 +50,11 @@ object PresAnnotationHistoryDAO {
|
||||
annotationInfo = "",
|
||||
updatedAt = new java.sql.Timestamp(annotationUpdatedAt)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
def deleteAnnotations(meetingId: String, pageId: String, userId: String, annotations: Array[String], annotationUpdatedAt: Long) = {
|
||||
DatabaseConnection.enqueue(
|
||||
DBIO.sequence(
|
||||
annotations.map { annotationId =>
|
||||
prepareDelete(meetingId, pageId, annotationId, userId, annotationUpdatedAt)
|
||||
}.toVector
|
||||
).transactionally
|
||||
TableQuery[PresAnnotationHistoryDbTableDef] ++= dbModels
|
||||
)
|
||||
|
||||
}
|
||||
}
|
@ -111,7 +111,6 @@ export const CURRENT_PAGE_ANNOTATIONS_QUERY = gql`query CurrentPageAnnotationsQu
|
||||
pres_annotation_curr(order_by: { lastUpdatedAt: desc }) {
|
||||
annotationId
|
||||
annotationInfo
|
||||
lastHistorySequence
|
||||
lastUpdatedAt
|
||||
pageId
|
||||
presentationId
|
||||
|
Loading…
Reference in New Issue
Block a user