Skip to content

Commit ec27e39

Browse files
committed
Optimize project performance
1 parent 16f5d77 commit ec27e39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+11423
-430
lines changed

app-wizard/elm/Wizard/Api/Models/BootstrapConfig.elm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,9 @@ decoder =
8282
|> D.required "registry" RegistryConfig.decoder
8383
|> D.required "lookAndFeel" LookAndFeelConfig.decoder
8484
|> D.required "organization" OrganizationConfig.decoder
85-
|> D.required "pluginSettings" (D.dict D.valueAsString)
86-
|> D.required "plugins" (D.list PluginInfo.decoder)
85+
-- TODO remove optional
86+
|> D.optional "pluginSettings" (D.dict D.valueAsString) Dict.empty
87+
|> D.optional "plugins" (D.list PluginInfo.decoder) []
8788
|> D.required "privacyAndSupport" PrivacyAndSupportConfig.decoder
8889
|> D.required "project" ProjectConfig.decoder
8990
|> D.required "submission" SubmissionConfig.decoder

app-wizard/elm/Wizard/Api/Models/ProjectDetail/CommentThread.elm

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Wizard.Api.Models.ProjectDetail.CommentThread exposing (CommentThread, commentCount, compare, decoder, isAssigned, isAuthor)
1+
module Wizard.Api.Models.ProjectDetail.CommentThread exposing (CommentThread, compare, decoder, isAssigned, isAuthor)
22

33
import Common.Api.Models.UserSuggestion as UserSuggestion exposing (UserSuggestion)
44
import Json.Decode as D exposing (Decoder)
@@ -48,11 +48,6 @@ compare a b =
4848
Time.compare a.createdAt b.createdAt
4949

5050

51-
commentCount : CommentThread -> Int
52-
commentCount =
53-
List.length << .comments
54-
55-
5651
isAssigned : CommentThread -> Bool
5752
isAssigned =
5853
Maybe.isJust << .assignedTo

app-wizard/elm/Wizard/Api/Models/ProjectDetail/Reply/ReplyValue.elm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module Wizard.Api.Models.ProjectDetail.Reply.ReplyValue exposing
33
, decoder
44
, encode
55
, getAnswerUuid
6-
, getChoiceUuid
6+
, getChoiceUuids
77
, getFileUuid
88
, getItemUuids
99
, getSelectedItemUuid
@@ -152,8 +152,8 @@ getAnswerUuid replyValue =
152152
""
153153

154154

155-
getChoiceUuid : ReplyValue -> List String
156-
getChoiceUuid replyValue =
155+
getChoiceUuids : ReplyValue -> List String
156+
getChoiceUuids replyValue =
157157
case replyValue of
158158
MultiChoiceReply uuids ->
159159
uuids

app-wizard/elm/Wizard/Api/Models/ProjectFileSimple.elm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module Wizard.Api.Models.ProjectFileSimple exposing
22
( ProjectFileSimple
33
, decoder
4+
, encode
45
)
56

67
import Json.Decode as D exposing (Decoder)
78
import Json.Decode.Pipeline as D
9+
import Json.Encode as E
810
import Uuid exposing (Uuid)
911

1012

@@ -23,3 +25,13 @@ decoder =
2325
|> D.required "contentType" D.string
2426
|> D.required "fileName" D.string
2527
|> D.required "fileSize" D.int
28+
29+
30+
encode : ProjectFileSimple -> E.Value
31+
encode file =
32+
E.object
33+
[ ( "uuid", Uuid.encode file.uuid )
34+
, ( "contentType", E.string file.contentType )
35+
, ( "fileName", E.string file.fileName )
36+
, ( "fileSize", E.int file.fileSize )
37+
]

app-wizard/elm/Wizard/Api/Models/ProjectQuestionnaire.elm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module Wizard.Api.Models.ProjectQuestionnaire exposing
2424
, getUnresolvedCommentCount
2525
, getWarnings
2626
, hasReply
27+
, hasTodo
2728
, isCurrentVersion
2829
, isPathVisible
2930
, itemSelectQuestionItemMissing
@@ -850,7 +851,7 @@ getItemTitleRecursive itemUuids questionnaire itemPath itemTemplateQuestions =
850851

851852
MultiChoiceQuestion common _ ->
852853
getReply common
853-
|> Maybe.map (ReplyValue.getChoiceUuid << .value)
854+
|> Maybe.map (ReplyValue.getChoiceUuids << .value)
854855
|> Maybe.andThen
855856
(\uuids ->
856857
if List.isEmpty uuids then
@@ -936,15 +937,15 @@ getItemUsageInItemSelectQuestions questionnaire itemUuid =
936937
-- Evaluations
937938

938939

939-
calculateUnansweredQuestionsForChapter : ProjectQuestionnaire -> Chapter -> Int
940+
calculateUnansweredQuestionsForChapter : ProjectQuestionnaire -> String -> Int
940941
calculateUnansweredQuestionsForChapter questionnaire =
941942
Tuple.first << evaluateChapter questionnaire
942943

943944

944-
evaluateChapter : ProjectQuestionnaire -> Chapter -> ( Int, Int )
945-
evaluateChapter questionnaire chapter =
946-
KnowledgeModel.getChapterQuestions chapter.uuid questionnaire.knowledgeModel
947-
|> List.map (evaluateQuestion questionnaire [ chapter.uuid ])
945+
evaluateChapter : ProjectQuestionnaire -> String -> ( Int, Int )
946+
evaluateChapter questionnaire chapterUuid =
947+
KnowledgeModel.getChapterQuestions chapterUuid questionnaire.knowledgeModel
948+
|> List.map (evaluateQuestion questionnaire [ chapterUuid ])
948949
|> List.foldl Tuple.sum ( 0, 0 )
949950

950951

app-wizard/elm/Wizard/Components/Questionnaire.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3678,7 +3678,7 @@ viewQuestionMultiChoice appState cfg model path question =
36783678

36793679
selectedChoicesUuids =
36803680
Dict.get (pathToString path) model.questionnaire.replies
3681-
|> Maybe.unwrap [] (.value >> ReplyValue.getChoiceUuid)
3681+
|> Maybe.unwrap [] (.value >> ReplyValue.getChoiceUuids)
36823682

36833683
clearReplyButton =
36843684
viewQuestionClearButton appState cfg path (not (List.isEmpty selectedChoicesUuids))

app-wizard/elm/Wizard/Components/Questionnaire/NavigationTree.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ viewChapterIndication : ProjectQuestionnaire -> Chapter -> Html msg
8989
viewChapterIndication questionnaire chapter =
9090
let
9191
unanswered =
92-
ProjectQuestionnaire.calculateUnansweredQuestionsForChapter questionnaire chapter
92+
ProjectQuestionnaire.calculateUnansweredQuestionsForChapter questionnaire chapter.uuid
9393
in
9494
if unanswered > 0 then
9595
Badge.light [ class "rounded-pill" ] [ text <| String.fromInt unanswered ]

0 commit comments

Comments
 (0)