Merge pull request 'Reinstate score badges, fix sorting' (#29) from recipe-scores into main
continuous-integration/drone/push Build is passing Details

Reviewed-on: #29
This commit is contained in:
3wordchant 2023-03-28 15:20:22 +00:00
commit af5565dcc5
3 changed files with 20 additions and 20 deletions

View File

@ -46,6 +46,7 @@ i.fas, i.fab {
.app-category { .app-category {
background-color: var(--light-blue); background-color: var(--light-blue);
color: var(--white); color: var(--white);
margin-left: 0.5rem;
} }
.card-description { .card-description {

View File

@ -39,7 +39,7 @@ type alias App =
, repository : Maybe String , repository : Maybe String
, versions : Maybe (List String) , versions : Maybe (List String)
, icon : Maybe String , icon : Maybe String
, status : String , status : Int
, slug : String , slug : String
, default_branch : String , default_branch : String
, website : Maybe String , website : Maybe String
@ -192,23 +192,23 @@ viewStatusBadge app =
let let
status_class = status_class =
case app.status of case app.status of
"1" -> 5 ->
"badge-success" "badge-success"
"2" -> 4 ->
"badge-info" "badge-info"
"3" -> 3 ->
"badge-warning" "badge-warning"
"4" -> 2 ->
"badge-danger" "badge-danger"
_ -> _ ->
"badge-dark" "badge-dark"
in in
span [ class ("card-link badge " ++ status_class) ] span [ class ("card-link badge " ++ status_class) ]
[ text ("Score: " ++ app.status) ] [ text ("Score: " ++ String.fromInt app.status) ]
viewApp : App -> String -> Html Msg viewApp : App -> String -> Html Msg
@ -309,12 +309,10 @@ loadREADME app =
} }
featuresDecoder : Decode.Decoder String
featuresDecoder = featuresDecoder =
-- get features.status if it's there
Decode.oneOf Decode.oneOf
[ Decode.at [ "status" ] Decode.string [ Decode.at [ "status" ] Decode.int
, Decode.succeed "" , Decode.succeed 5
] ]

View File

@ -114,7 +114,7 @@ filterAppsScore apps score =
case score of case score of
Just s -> Just s ->
List.filter (\app -> List.filter (\app ->
app.status <= s app.status >= s
) apps ) apps
Nothing -> Nothing ->
apps apps
@ -231,23 +231,23 @@ viewStatusBadge app =
let let
status_class = status_class =
case app.status of case app.status of
1 -> 5 ->
"badge-success" "badge-success"
2 -> 4 ->
"badge-info" "badge-info"
3 -> 3 ->
"badge-warning" "badge-warning"
4 -> 2 ->
"badge-danger" "badge-danger"
_ -> _ ->
"badge-dark" "badge-dark"
in in
span [ class ("card-link badge " ++ status_class) ] span [ class ("card-link badge " ++ status_class) ]
[ text ("Score: " ++ String.fromInt app.status) ] [ text ("Status: " ++ String.fromInt app.status) ]
viewApp : App -> Html Msg viewApp : App -> Html Msg
@ -303,7 +303,7 @@ viewApp app =
, p [ class "card-description" ] [ text (ellipsis 100 (withDefault "" app.description)) ] , p [ class "card-description" ] [ text (ellipsis 100 (withDefault "" app.description)) ]
] ]
, div [ class "footer" ] , div [ class "footer" ]
[ span [ class "badge app-category" ] [ text app.category ]] [ viewStatusBadge app, span [ class "badge app-category" ] [ text app.category ]]
] ]
] ]
@ -349,10 +349,11 @@ viewApps model =
, label [ for "level" ] [ text " and show only items that have at least " ] , label [ for "level" ] [ text " and show only items that have at least " ]
, select [ class "search-dropdown", id "level", onInput FilterScore ] [ , select [ class "search-dropdown", id "level", onInput FilterScore ] [
option [ ] [ text "any" ] option [ ] [ text "any" ]
, option [ value "1" ] [ text "1 (production)" ] , option [ value "5" ] [ text "5 (production)" ]
, option [ value "2" ] [ text "2 (beta)" ] , option [ value "4" ] [ text "4 (beta)" ]
, option [ value "3" ] [ text "3 (alpha)" ] , option [ value "3" ] [ text "3 (alpha)" ]
, option [ value "4" ] [ text "4 (pre-alpha)" ] , option [ value "2" ] [ text "2 (pre-alpha)" ]
, option [ value "1" ] [ text "1 (work-in-progress)" ]
] ]
, text "builds " , text "builds "
] ]
@ -364,7 +365,7 @@ viewApps model =
(List.map viewApp (List.map viewApp
(model.results (model.results
|> List.sortWith |> List.sortWith
(by .status ASC (by .status DESC
|> andThen (String.toLower << .name) ASC |> andThen (String.toLower << .name) ASC
) )
) )