Address review errors.

This commit is contained in:
Dillon Kearns 2022-02-04 10:17:53 -08:00
parent 3c5b171458
commit 43866be8d5
3 changed files with 108 additions and 70 deletions

View File

@ -83,7 +83,6 @@ So it's best to use that mental model to avoid confusion.
-}
import Dict exposing (Dict)
import Pages.Internal.ApplicationType exposing (ApplicationType)
import Pages.Internal.StaticHttpBody as Body
import Pages.StaticHttp.Request as HashRequest

View File

@ -52,7 +52,6 @@ and describe your use case!
-}
import DataSource exposing (DataSource)
import Dict
import Json.Decode
import Json.Encode as Encode
import Pages.Internal.StaticHttpBody as Body

View File

@ -266,43 +266,6 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
else
True
)
failedRequests : List BuildError
failedRequests =
staticResponses
|> Dict.toList
|> List.concatMap
(\( path, NotFetched request _ ) ->
let
staticRequestsStatus : StaticHttpRequest.Status ()
staticRequestsStatus =
StaticHttpRequest.cacheRequestResolution
ApplicationType.Cli
request
usableRawResponses
usableRawResponses : RequestsAndPending
usableRawResponses =
allRawResponses
maybePermanentError : Maybe StaticHttpRequest.Error
maybePermanentError =
case staticRequestsStatus of
StaticHttpRequest.HasPermanentError theError ->
Just theError
_ ->
Nothing
decoderErrors : List BuildError
decoderErrors =
maybePermanentError
|> Maybe.map (StaticHttpRequest.toBuildError path)
|> Maybe.map List.singleton
|> Maybe.withDefault []
in
decoderErrors
)
in
if pendingRequests then
let
@ -382,6 +345,49 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
-- )
--
-- Ok okSiteStaticData ->
let
allErrors : List BuildError
allErrors =
let
failedRequests : List BuildError
failedRequests =
staticResponses
|> Dict.toList
|> List.concatMap
(\( path, NotFetched request _ ) ->
let
staticRequestsStatus : StaticHttpRequest.Status ()
staticRequestsStatus =
StaticHttpRequest.cacheRequestResolution
ApplicationType.Cli
request
usableRawResponses
usableRawResponses : RequestsAndPending
usableRawResponses =
allRawResponses
maybePermanentError : Maybe StaticHttpRequest.Error
maybePermanentError =
case staticRequestsStatus of
StaticHttpRequest.HasPermanentError theError ->
Just theError
_ ->
Nothing
decoderErrors : List BuildError
decoderErrors =
maybePermanentError
|> Maybe.map (StaticHttpRequest.toBuildError path)
|> Maybe.map List.singleton
|> Maybe.withDefault []
in
decoderErrors
)
generatedFileErrors : List BuildError
generatedFileErrors =
let
generatedFiles : List (Result String { path : List String, content : String })
generatedFiles =
@ -392,13 +398,7 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
StaticHttpRequest.resolve ApplicationType.Cli
(buildTimeFilesRequest config)
(allRawResponses |> Dict.Extra.filterMap (\_ value -> Just value))
allErrors : List BuildError
allErrors =
errors ++ failedRequests ++ generatedFileErrors
generatedFileErrors : List BuildError
generatedFileErrors =
in
generatedFiles
|> List.filterMap
(\result ->
@ -418,6 +418,8 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
}
)
in
errors ++ failedRequests ++ generatedFileErrors
in
( model.staticResponses
, case encode allRawResponses staticResponses of
Ok encodedResponses ->
@ -462,6 +464,44 @@ nextStep config ({ allRawResponses, errors } as model) maybeRoutes =
)
Err error_ ->
let
failedRequests : List BuildError
failedRequests =
staticResponses
|> Dict.toList
|> List.concatMap
(\( path, NotFetched request _ ) ->
let
staticRequestsStatus : StaticHttpRequest.Status ()
staticRequestsStatus =
StaticHttpRequest.cacheRequestResolution
ApplicationType.Cli
request
usableRawResponses
usableRawResponses : RequestsAndPending
usableRawResponses =
allRawResponses
maybePermanentError : Maybe StaticHttpRequest.Error
maybePermanentError =
case staticRequestsStatus of
StaticHttpRequest.HasPermanentError theError ->
Just theError
_ ->
Nothing
decoderErrors : List BuildError
decoderErrors =
maybePermanentError
|> Maybe.map (StaticHttpRequest.toBuildError path)
|> Maybe.map List.singleton
|> Maybe.withDefault []
in
decoderErrors
)
in
( model.staticResponses
, Finish
(Errors <|