From 33ddb9e3906402ad09ed1dd901f2810e25f6676f Mon Sep 17 00:00:00 2001 From: 3wc <3wc.git@doesthisthing.work> Date: Sun, 25 Apr 2021 15:37:32 +0200 Subject: [PATCH] Parse app status score as int --- src/Pages/Top.elm | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/Pages/Top.elm b/src/Pages/Top.elm index c4dfa36..5366a63 100644 --- a/src/Pages/Top.elm +++ b/src/Pages/Top.elm @@ -33,7 +33,7 @@ type alias App = , repository : Maybe String , versions : Maybe (List String) , icon : Maybe String - , status : String + , status : Int , slug : String , website : Maybe String } @@ -102,13 +102,13 @@ body model = appScore : App -> Int appScore app = case app.status of - "1" -> + 1 -> 1 - "2" -> + 2 -> 2 - "3" -> + 3 -> 3 - "4" -> + 4 -> 4 _ -> 5 @@ -118,25 +118,19 @@ viewStatusBadge app = let status_class = case app.status of - "1" -> + 1 -> "badge-success" - "2" -> + 2 -> "badge-info" - "3" -> + 3 -> "badge-warning" - "4" -> + 4 -> "badge-danger" _ -> "badge-dark" - status_score = - case app.status of - "" -> - "?" - score -> - score in span [ class ("card-link badge " ++ status_class) ] - [ text ("Score: " ++ status_score) ] + [ text ("Score: " ++ String.fromInt app.status) ] viewApp : App -> Html Msg viewApp app = @@ -228,8 +222,8 @@ loadApps = featuresDecoder = (Decode.oneOf - [ Decode.at [ "status" ] Decode.string - , Decode.succeed "" + [ Decode.at [ "status" ] Decode.int + , Decode.succeed 5 ] )