reduce the platform list and add platform link to hydra (#76)

fixes #73
fixes #72
This commit is contained in:
Rok Garbas 2020-06-10 01:53:17 +02:00 committed by GitHub
parent 554236f4a6
commit b7df41a891
Failed to generate hash of commit
5 changed files with 118 additions and 26 deletions

View file

@ -30,7 +30,7 @@ click_log.basic_config(logger)
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
INDEX_SCHEMA_VERSION = 3 INDEX_SCHEMA_VERSION = 4
ANALYSIS = { ANALYSIS = {
"analyzer": { "analyzer": {
"nixAttrName": { "nixAttrName": {
@ -147,6 +147,7 @@ MAPPING = {
"package_platforms": {"type": "keyword"}, "package_platforms": {"type": "keyword"},
"package_position": {"type": "text"}, "package_position": {"type": "text"},
"package_homepage": {"type": "keyword"}, "package_homepage": {"type": "keyword"},
"package_system": {"type": "keyword"},
# Options fields # Options fields
"option_name": { "option_name": {
"type": "text", "type": "text",
@ -357,6 +358,7 @@ def get_packages(evaluation, evaluation_builds):
package_platforms=[i for i in platforms if i], package_platforms=[i for i in platforms if i],
package_position=position, package_position=position,
package_homepage=data["meta"].get("homepage"), package_homepage=data["meta"].get("homepage"),
package_system=data["system"],
) )
logger.debug(f"get_packages: Found {len(packages)} packages") logger.debug(f"get_packages: Found {len(packages)} packages")

View file

@ -109,10 +109,11 @@ view model =
viewSuccess : viewSuccess :
Maybe String String
-> Maybe String
-> Search.Result ResultItemSource -> Search.Result ResultItemSource
-> Html Msg -> Html Msg
viewSuccess showDetailsFor result = viewSuccess channel showDetailsFor result =
div [ class "search-result" ] div [ class "search-result" ]
[ table [ class "table table-hover" ] [ table [ class "table table-hover" ]
[ thead [] [ thead []

View file

@ -64,6 +64,7 @@ type alias ResultItemSource =
, platforms : List String , platforms : List String
, position : Maybe String , position : Maybe String
, homepage : Maybe String , homepage : Maybe String
, system : String
} }
@ -125,10 +126,11 @@ view model =
viewSuccess : viewSuccess :
Maybe String String
-> Maybe String
-> Search.Result ResultItemSource -> Search.Result ResultItemSource
-> Html Msg -> Html Msg
viewSuccess showDetailsFor result = viewSuccess channel showDetailsFor result =
div [ class "search-result" ] div [ class "search-result" ]
[ table [ class "table table-hover" ] [ table [ class "table table-hover" ]
[ thead [] [ thead []
@ -142,7 +144,7 @@ viewSuccess showDetailsFor result =
, tbody , tbody
[] []
(List.concatMap (List.concatMap
(viewResultItem showDetailsFor) (viewResultItem channel showDetailsFor)
result.hits.hits result.hits.hits
) )
] ]
@ -150,14 +152,15 @@ viewSuccess showDetailsFor result =
viewResultItem : viewResultItem :
Maybe String String
-> Maybe String
-> Search.ResultItem ResultItemSource -> Search.ResultItem ResultItemSource
-> List (Html Msg) -> List (Html Msg)
viewResultItem showDetailsFor item = viewResultItem channel showDetailsFor item =
let let
packageDetails = packageDetails =
if Just item.id == showDetailsFor then if Just item.id == showDetailsFor then
[ td [ colspan 4 ] [ viewResultItemDetails item ] [ td [ colspan 4 ] [ viewResultItemDetails channel item ]
] ]
else else
@ -173,9 +176,10 @@ viewResultItem showDetailsFor item =
viewResultItemDetails : viewResultItemDetails :
Search.ResultItem ResultItemSource String
-> Search.ResultItem ResultItemSource
-> Html Msg -> Html Msg
viewResultItemDetails item = viewResultItemDetails channel item =
let let
default = default =
"Not specified" "Not specified"
@ -222,8 +226,32 @@ viewResultItemDetails item =
-- TODO: add links to hydra for hydra_platforms -- TODO: add links to hydra for hydra_platforms
-- example: https://hydra.nixos.org/job/nixos/release-20.03/nixpkgs.gnome3.accerciser.i686-linux -- example: https://hydra.nixos.org/job/nixos/release-20.03/nixpkgs.gnome3.accerciser.i686-linux
allowedPlatforms platform =
List.member platform
[ "x86_64-linux"
, "aarch64-linux"
, "x86_64-darwin"
, "i686-linux"
]
showPlatforms platforms =
platforms
|> List.filter allowedPlatforms
|> List.map showPlatform
showPlatform platform = showPlatform platform =
li [] [ text platform ] li []
[ case Search.channelDetailsFromId channel of
Just channelDetails ->
a
[ href <| "https://hydra.nixos.org/job/" ++ channelDetails.jobset ++ "/nixpkgs." ++ item.source.attr_name ++ "." ++ item.source.system
]
[ text platform
]
Nothing ->
text platform
]
showLicence license = showLicence license =
li [] li []
@ -263,7 +291,7 @@ viewResultItemDetails item =
-- TODO: point to correct branch/channel -- TODO: point to correct branch/channel
, dd [] [ withDefault asGithubLink item.source.position ] , dd [] [ withDefault asGithubLink item.source.position ]
, dt [] [ text "Platforms" ] , dt [] [ text "Platforms" ]
, dd [] [ ul [ class "inline" ] <| List.map showPlatform item.source.platforms ] , dd [] [ ul [ class "inline" ] <| showPlatforms item.source.platforms ]
, dt [] [ text "Homepage" ] , dt [] [ text "Homepage" ]
, dd [] [ withDefault asLink item.source.homepage ] , dd [] [ withDefault asLink item.source.homepage ]
, dt [] [ text "Licenses" ] , dt [] [ text "Licenses" ]
@ -442,6 +470,7 @@ decodeResultItemSource =
|> Json.Decode.Pipeline.required "package_platforms" (Json.Decode.list Json.Decode.string) |> Json.Decode.Pipeline.required "package_platforms" (Json.Decode.list Json.Decode.string)
|> Json.Decode.Pipeline.required "package_position" (Json.Decode.nullable Json.Decode.string) |> Json.Decode.Pipeline.required "package_position" (Json.Decode.nullable Json.Decode.string)
|> Json.Decode.Pipeline.required "package_homepage" (Json.Decode.nullable Json.Decode.string) |> Json.Decode.Pipeline.required "package_homepage" (Json.Decode.nullable Json.Decode.string)
|> Json.Decode.Pipeline.required "package_system" Json.Decode.string
decodeResultPackageLicense : Json.Decode.Decoder ResultPackageLicense decodeResultPackageLicense : Json.Decode.Decoder ResultPackageLicense

View file

@ -4,6 +4,7 @@ module Search exposing
, Options , Options
, Result , Result
, ResultItem , ResultItem
, channelDetailsFromId
, decodeResult , decodeResult
, init , init
, makeRequest , makeRequest
@ -221,11 +222,67 @@ createUrl path channel query showDetailsFor from size =
-- VIEW -- VIEW
type Channel
= Unstable
| Release_19_09
| Release_20_03
type alias ChannelDetails =
{ id : String
, title : String
, jobset : String
}
channelDetails : Channel -> ChannelDetails
channelDetails channel =
case channel of
Unstable ->
ChannelDetails "unstable" "unstable" "nixos/trunk-combined"
Release_19_09 ->
ChannelDetails "19.09" "19.09" "nixos/release-19.09"
Release_20_03 ->
ChannelDetails "20.03" "20.03" "nixos/release-20.03"
channelFromId : String -> Maybe Channel
channelFromId channel_id =
case channel_id of
"unstable" ->
Just Unstable
"19.09" ->
Just Release_19_09
"20.03" ->
Just Release_20_03
_ ->
Nothing
channelDetailsFromId : String -> Maybe ChannelDetails
channelDetailsFromId channel_id =
channelFromId channel_id
|> Maybe.map channelDetails
channels : List String
channels =
[ "unstable"
, "20.03"
, "19.09"
]
view : view :
String String
-> String -> String
-> Model a -> Model a
-> (Maybe String -> Result a -> Html b) -> (String -> Maybe String -> Result a -> Html b)
-> (Msg a -> b) -> (Msg a -> b)
-> Html b -> Html b
view path title model viewSuccess outMsg = view path title model viewSuccess outMsg =
@ -249,16 +306,19 @@ view path title model viewSuccess outMsg =
[ text " in " ] [ text " in " ]
, select , select
[ onInput (\x -> outMsg (ChannelChange x)) ] [ onInput (\x -> outMsg (ChannelChange x)) ]
[ option (List.filterMap
[ value "unstable" ] (\channel_id ->
[ text "unstable" ] channelDetailsFromId channel_id
, option |> Maybe.map
[ value "20.03" ] (\channel ->
[ text "20.03" ] option
, option [ value channel.id
[ value "19.09" ] ]
[ text "19.09" ] [ text channel.title ]
] )
)
channels
)
, strong [] , strong []
[ text " channel." ] [ text " channel." ]
] ]
@ -299,7 +359,7 @@ view path title model viewSuccess outMsg =
] ]
] ]
, viewPager outMsg model result path , viewPager outMsg model result path
, viewSuccess model.showDetailsFor result , viewSuccess model.channel model.showDetailsFor result
, viewPager outMsg model result path , viewPager outMsg model result path
] ]

View file

@ -6,7 +6,7 @@ const {Elm} = require('./Main');
Elm.Main.init({ Elm.Main.init({
flags: { flags: {
elasticsearchMappingSchemaVersion: process.env.ELASTICSEARCH_MAPPING_SCHEMA_VERSION || 2, elasticsearchMappingSchemaVersion: process.env.ELASTICSEARCH_MAPPING_SCHEMA_VERSION || 4,
elasticsearchUrl: process.env.ELASTICSEARCH_URL || 'https://nixos-search-5886075189.us-east-1.bonsaisearch.net:443', elasticsearchUrl: process.env.ELASTICSEARCH_URL || 'https://nixos-search-5886075189.us-east-1.bonsaisearch.net:443',
elasticsearchUsername : process.env.ELASTICSEARCH_USERNAME || 'z3ZFJ6y2mR', elasticsearchUsername : process.env.ELASTICSEARCH_USERNAME || 'z3ZFJ6y2mR',
elasticsearchPassword : process.env.ELASTICSEARCH_PASSWORD || 'ds8CEvALPf9pui7XG' elasticsearchPassword : process.env.ELASTICSEARCH_PASSWORD || 'ds8CEvALPf9pui7XG'