Skip to content

Commit

Permalink
Add throttling to KM editor
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Oct 8, 2024
1 parent d8d97f7 commit 8f2e9ac
Show file tree
Hide file tree
Showing 31 changed files with 525 additions and 85 deletions.
44 changes: 44 additions & 0 deletions engine-shared/elm/Shared/Data/Event.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event exposing
, encode
, getEntityVisibleName
, getUuid
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -585,3 +586,46 @@ getEntityVisibleName event =

_ ->
Nothing


squash : Event -> Event -> Event
squash old new =
case ( old, new ) of
( EditChapterEvent oldEditChapterData _, EditChapterEvent newEditChapterData commonData ) ->
EditChapterEvent (EditChapterEventData.squash oldEditChapterData newEditChapterData) commonData

( EditMetricEvent oldEditMetricData _, EditMetricEvent newEditMetricData commonData ) ->
EditMetricEvent (EditMetricEventData.squash oldEditMetricData newEditMetricData) commonData

( EditPhaseEvent oldEditPhaseData _, EditPhaseEvent newEditPhaseData commonData ) ->
EditPhaseEvent (EditPhaseEventData.squash oldEditPhaseData newEditPhaseData) commonData

( EditTagEvent oldEditTagData _, EditTagEvent newEditTagData commonData ) ->
EditTagEvent (EditTagEventData.squash oldEditTagData newEditTagData) commonData

( EditIntegrationEvent oldEditIntegrationData _, EditIntegrationEvent newEditIntegrationData commonData ) ->
EditIntegrationEvent (EditIntegrationEventData.squash oldEditIntegrationData newEditIntegrationData) commonData

( EditQuestionEvent oldEditQuestionData _, EditQuestionEvent newEditQuestionData commonData ) ->
EditQuestionEvent (EditQuestionEventData.squash oldEditQuestionData newEditQuestionData) commonData

( EditAnswerEvent oldEditAnswerData _, EditAnswerEvent newEditAnswerData commonData ) ->
EditAnswerEvent (EditAnswerEventData.squash oldEditAnswerData newEditAnswerData) commonData

( EditChoiceEvent oldEditChoiceData _, EditChoiceEvent newEditChoiceData commonData ) ->
EditChoiceEvent (EditChoiceEventData.squash oldEditChoiceData newEditChoiceData) commonData

( EditReferenceEvent oldEditReferenceData _, EditReferenceEvent newEditReferenceData commonData ) ->
EditReferenceEvent (EditReferenceEventData.squash oldEditReferenceData newEditReferenceData) commonData

( EditExpertEvent oldEditExpertData _, EditExpertEvent newEditExpertData commonData ) ->
EditExpertEvent (EditExpertEventData.squash oldEditExpertData newEditExpertData) commonData

( EditResourceCollectionEvent oldEditResourceCollectionData _, EditResourceCollectionEvent newEditResourceCollectionData commonData ) ->
EditResourceCollectionEvent (EditResourceCollectionEventData.squash oldEditResourceCollectionData newEditResourceCollectionData) commonData

( EditResourcePageEvent oldEditResourcePageData _, EditResourcePageEvent newEditResourcePageData commonData ) ->
EditResourcePageEvent (EditResourcePageEventData.squash oldEditResourcePageData newEditResourcePageData) commonData

_ ->
new
11 changes: 11 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditAnswerEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditAnswerEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -65,3 +66,13 @@ apply eventData answer =
, followUpUuids = EventField.applyChildren eventData.followUpUuids answer.followUpUuids
, annotations = EventField.getValueWithDefault eventData.annotations answer.annotations
}


squash : EditAnswerEventData -> EditAnswerEventData -> EditAnswerEventData
squash oldData newData =
{ label = EventField.squash oldData.label newData.label
, advice = EventField.squash oldData.advice newData.advice
, metricMeasures = EventField.squash oldData.metricMeasures newData.metricMeasures
, followUpUuids = EventField.squash oldData.followUpUuids newData.followUpUuids
, annotations = EventField.squash oldData.annotations newData.annotations
}
10 changes: 10 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditChapterEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditChapterEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -59,3 +60,12 @@ apply eventData chapter =
, questionUuids = EventField.applyChildren eventData.questionUuids chapter.questionUuids
, annotations = EventField.getValueWithDefault eventData.annotations chapter.annotations
}


squash : EditChapterEventData -> EditChapterEventData -> EditChapterEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, text = EventField.squash oldData.text newData.text
, questionUuids = EventField.squash oldData.questionUuids newData.questionUuids
, annotations = EventField.squash oldData.annotations newData.annotations
}
8 changes: 8 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditChoiceEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditChoiceEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -48,3 +49,10 @@ apply eventData choice =
| label = EventField.getValueWithDefault eventData.label choice.label
, annotations = EventField.getValueWithDefault eventData.annotations choice.annotations
}


squash : EditChoiceEventData -> EditChoiceEventData -> EditChoiceEventData
squash oldData newData =
{ label = EventField.squash oldData.label newData.label
, annotations = EventField.squash oldData.annotations newData.annotations
}
9 changes: 9 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditExpertEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditExpertEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -53,3 +54,11 @@ apply eventData expert =
, email = EventField.getValueWithDefault eventData.email expert.email
, annotations = EventField.getValueWithDefault eventData.annotations expert.annotations
}


squash : EditExpertEventData -> EditExpertEventData -> EditExpertEventData
squash oldData newData =
{ name = EventField.squash oldData.name newData.name
, email = EventField.squash oldData.email newData.email
, annotations = EventField.squash oldData.annotations newData.annotations
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Shared.Data.Event.EditIntegrationApiEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -88,3 +89,22 @@ init =
, responseItemId = EventField.empty
, responseItemTemplate = EventField.empty
}


squash : EditIntegrationApiEventData -> EditIntegrationApiEventData -> EditIntegrationApiEventData
squash oldData newData =
{ id = EventField.squash oldData.id newData.id
, name = EventField.squash oldData.name newData.name
, props = EventField.squash oldData.props newData.props
, logo = EventField.squash oldData.logo newData.logo
, itemUrl = EventField.squash oldData.itemUrl newData.itemUrl
, annotations = EventField.squash oldData.annotations newData.annotations
, requestMethod = EventField.squash oldData.requestMethod newData.requestMethod
, requestUrl = EventField.squash oldData.requestUrl newData.requestUrl
, requestHeaders = EventField.squash oldData.requestHeaders newData.requestHeaders
, requestBody = EventField.squash oldData.requestBody newData.requestBody
, requestEmptySearch = EventField.squash oldData.requestEmptySearch newData.requestEmptySearch
, responseListField = EventField.squash oldData.responseListField newData.responseListField
, responseItemId = EventField.squash oldData.responseItemId newData.responseItemId
, responseItemTemplate = EventField.squash oldData.responseItemTemplate newData.responseItemTemplate
}
14 changes: 14 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditIntegrationEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Shared.Data.Event.EditIntegrationEventData exposing
, getEntityVisibleName
, getTypeString
, map
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -108,3 +109,16 @@ map apiIntegration widgetIntegration integration =

EditIntegrationWidgetEvent data ->
widgetIntegration data


squash : EditIntegrationEventData -> EditIntegrationEventData -> EditIntegrationEventData
squash old new =
case ( old, new ) of
( EditIntegrationApiEvent oldData, EditIntegrationApiEvent newData ) ->
EditIntegrationApiEvent (EditIntegrationApiEventData.squash oldData newData)

( EditIntegrationWidgetEvent oldData, EditIntegrationWidgetEvent newData ) ->
EditIntegrationWidgetEvent (EditIntegrationWidgetEventData.squash oldData newData)

_ ->
new
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Shared.Data.Event.EditIntegrationWidgetEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -59,3 +60,15 @@ init =
, annotations = EventField.empty
, widgetUrl = EventField.empty
}


squash : EditIntegrationWidgetEventData -> EditIntegrationWidgetEventData -> EditIntegrationWidgetEventData
squash oldData newData =
{ id = EventField.squash oldData.id newData.id
, name = EventField.squash oldData.name newData.name
, props = EventField.squash oldData.props newData.props
, logo = EventField.squash oldData.logo newData.logo
, itemUrl = EventField.squash oldData.itemUrl newData.itemUrl
, annotations = EventField.squash oldData.annotations newData.annotations
, widgetUrl = EventField.squash oldData.widgetUrl newData.widgetUrl
}
10 changes: 10 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditMetricEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditMetricEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -59,3 +60,12 @@ apply eventData metric =
, description = EventField.getValueWithDefault eventData.description metric.description
, annotations = EventField.getValueWithDefault eventData.annotations metric.annotations
}


squash : EditMetricEventData -> EditMetricEventData -> EditMetricEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, abbreviation = EventField.squash oldData.abbreviation newData.abbreviation
, description = EventField.squash oldData.description newData.description
, annotations = EventField.squash oldData.annotations newData.annotations
}
9 changes: 9 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditPhaseEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Shared.Data.Event.EditPhaseEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -54,3 +55,11 @@ apply eventData phase =
, description = EventField.getValueWithDefault eventData.description phase.description
, annotations = EventField.getValueWithDefault eventData.annotations phase.annotations
}


squash : EditPhaseEventData -> EditPhaseEventData -> EditPhaseEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, description = EventField.squash oldData.description newData.description
, annotations = EventField.squash oldData.annotations newData.annotations
}
26 changes: 26 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditQuestionEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Shared.Data.Event.EditQuestionEventData exposing
, getEntityVisibleName
, getTypeString
, map
, squash
)

import Dict
Expand Down Expand Up @@ -173,3 +174,28 @@ map optionsQuestion listQuestion valueQuestion integrationQuestion multiChoiceQu

EditQuestionItemSelectEvent data ->
itemSelectQuestion data


squash : EditQuestionEventData -> EditQuestionEventData -> EditQuestionEventData
squash old new =
case ( old, new ) of
( EditQuestionOptionsEvent oldData, EditQuestionOptionsEvent newData ) ->
EditQuestionOptionsEvent (EditQuestionOptionsEventData.squash oldData newData)

( EditQuestionListEvent oldData, EditQuestionListEvent newData ) ->
EditQuestionListEvent (EditQuestionListEventData.squash oldData newData)

( EditQuestionValueEvent oldData, EditQuestionValueEvent newData ) ->
EditQuestionValueEvent (EditQuestionValueEventData.squash oldData newData)

( EditQuestionIntegrationEvent oldData, EditQuestionIntegrationEvent newData ) ->
EditQuestionIntegrationEvent (EditQuestionIntegrationEventData.squash oldData newData)

( EditQuestionMultiChoiceEvent oldData, EditQuestionMultiChoiceEvent newData ) ->
EditQuestionMultiChoiceEvent (EditQuestionMultiChoiceEventData.squash oldData newData)

( EditQuestionItemSelectEvent oldData, EditQuestionItemSelectEvent newData ) ->
EditQuestionItemSelectEvent (EditQuestionItemSelectEventData.squash oldData newData)

_ ->
new
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Shared.Data.Event.EditQuestionIntegrationEventData exposing
, decoder
, encode
, init
, squash
)

import Dict exposing (Dict)
Expand Down Expand Up @@ -68,3 +69,17 @@ init =
, props = EventField.empty
, annotations = EventField.empty
}


squash : EditQuestionIntegrationEventData -> EditQuestionIntegrationEventData -> EditQuestionIntegrationEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, text = EventField.squash oldData.text newData.text
, requiredPhaseUuid = EventField.squash oldData.requiredPhaseUuid newData.requiredPhaseUuid
, tagUuids = EventField.squash oldData.tagUuids newData.tagUuids
, referenceUuids = EventField.squash oldData.referenceUuids newData.referenceUuids
, expertUuids = EventField.squash oldData.expertUuids newData.expertUuids
, integrationUuid = EventField.squash oldData.integrationUuid newData.integrationUuid
, props = EventField.squash oldData.props newData.props
, annotations = EventField.squash oldData.annotations newData.annotations
}
14 changes: 14 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditQuestionItemSelectData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Shared.Data.Event.EditQuestionItemSelectData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -63,3 +64,16 @@ init =
, listQuestionUuid = EventField.empty
, annotations = EventField.empty
}


squash : EditQuestionItemSelectEventData -> EditQuestionItemSelectEventData -> EditQuestionItemSelectEventData
squash left right =
{ title = EventField.squash left.title right.title
, text = EventField.squash left.text right.text
, requiredPhaseUuid = EventField.squash left.requiredPhaseUuid right.requiredPhaseUuid
, tagUuids = EventField.squash left.tagUuids right.tagUuids
, referenceUuids = EventField.squash left.referenceUuids right.referenceUuids
, expertUuids = EventField.squash left.expertUuids right.expertUuids
, listQuestionUuid = EventField.squash left.listQuestionUuid right.listQuestionUuid
, annotations = EventField.squash left.annotations right.annotations
}
14 changes: 14 additions & 0 deletions engine-shared/elm/Shared/Data/Event/EditQuestionListEventData.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Shared.Data.Event.EditQuestionListEventData exposing
, decoder
, encode
, init
, squash
)

import Json.Decode as D exposing (Decoder)
Expand Down Expand Up @@ -63,3 +64,16 @@ init =
, itemTemplateQuestionUuids = EventField.empty
, annotations = EventField.empty
}


squash : EditQuestionListEventData -> EditQuestionListEventData -> EditQuestionListEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, text = EventField.squash oldData.text newData.text
, requiredPhaseUuid = EventField.squash oldData.requiredPhaseUuid newData.requiredPhaseUuid
, tagUuids = EventField.squash oldData.tagUuids newData.tagUuids
, referenceUuids = EventField.squash oldData.referenceUuids newData.referenceUuids
, expertUuids = EventField.squash oldData.expertUuids newData.expertUuids
, itemTemplateQuestionUuids = EventField.squash oldData.itemTemplateQuestionUuids newData.itemTemplateQuestionUuids
, annotations = EventField.squash oldData.annotations newData.annotations
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Shared.Data.Event.EditQuestionMultiChoiceEventData exposing (EditQuestionMultiChoiceEventData, decoder, encode, init)
module Shared.Data.Event.EditQuestionMultiChoiceEventData exposing (EditQuestionMultiChoiceEventData, decoder, encode, init, squash)

import Json.Decode as D exposing (Decoder)
import Json.Decode.Pipeline as D
Expand Down Expand Up @@ -58,3 +58,16 @@ init =
, choiceUuids = EventField.empty
, annotations = EventField.empty
}


squash : EditQuestionMultiChoiceEventData -> EditQuestionMultiChoiceEventData -> EditQuestionMultiChoiceEventData
squash oldData newData =
{ title = EventField.squash oldData.title newData.title
, text = EventField.squash oldData.text newData.text
, requiredPhaseUuid = EventField.squash oldData.requiredPhaseUuid newData.requiredPhaseUuid
, tagUuids = EventField.squash oldData.tagUuids newData.tagUuids
, referenceUuids = EventField.squash oldData.referenceUuids newData.referenceUuids
, expertUuids = EventField.squash oldData.expertUuids newData.expertUuids
, choiceUuids = EventField.squash oldData.choiceUuids newData.choiceUuids
, annotations = EventField.squash oldData.annotations newData.annotations
}
Loading

0 comments on commit 8f2e9ac

Please sign in to comment.