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__))
INDEX_SCHEMA_VERSION = 3
INDEX_SCHEMA_VERSION = 4
ANALYSIS = {
"analyzer": {
"nixAttrName": {
@ -147,6 +147,7 @@ MAPPING = {
"package_platforms": {"type": "keyword"},
"package_position": {"type": "text"},
"package_homepage": {"type": "keyword"},
"package_system": {"type": "keyword"},
# Options fields
"option_name": {
"type": "text",
@ -357,6 +358,7 @@ def get_packages(evaluation, evaluation_builds):
package_platforms=[i for i in platforms if i],
package_position=position,
package_homepage=data["meta"].get("homepage"),
package_system=data["system"],
)
logger.debug(f"get_packages: Found {len(packages)} packages")

View file

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

View file

@ -64,6 +64,7 @@ type alias ResultItemSource =
, platforms : List String
, position : Maybe String
, homepage : Maybe String
, system : String
}
@ -125,10 +126,11 @@ view model =
viewSuccess :
Maybe String
String
-> Maybe String
-> Search.Result ResultItemSource
-> Html Msg
viewSuccess showDetailsFor result =
viewSuccess channel showDetailsFor result =
div [ class "search-result" ]
[ table [ class "table table-hover" ]
[ thead []
@ -142,7 +144,7 @@ viewSuccess showDetailsFor result =
, tbody
[]
(List.concatMap
(viewResultItem showDetailsFor)
(viewResultItem channel showDetailsFor)
result.hits.hits
)
]
@ -150,14 +152,15 @@ viewSuccess showDetailsFor result =
viewResultItem :
Maybe String
String
-> Maybe String
-> Search.ResultItem ResultItemSource
-> List (Html Msg)
viewResultItem showDetailsFor item =
viewResultItem channel showDetailsFor item =
let
packageDetails =
if Just item.id == showDetailsFor then
[ td [ colspan 4 ] [ viewResultItemDetails item ]
[ td [ colspan 4 ] [ viewResultItemDetails channel item ]
]
else
@ -173,9 +176,10 @@ viewResultItem showDetailsFor item =
viewResultItemDetails :
Search.ResultItem ResultItemSource
String
-> Search.ResultItem ResultItemSource
-> Html Msg
viewResultItemDetails item =
viewResultItemDetails channel item =
let
default =
"Not specified"
@ -222,8 +226,32 @@ viewResultItemDetails item =
-- TODO: add links to hydra for hydra_platforms
-- 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 =
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 =
li []
@ -263,7 +291,7 @@ viewResultItemDetails item =
-- TODO: point to correct branch/channel
, dd [] [ withDefault asGithubLink item.source.position ]
, dt [] [ text "Platforms" ]
, dd [] [ ul [ class "inline" ] <| List.map showPlatform item.source.platforms ]
, dd [] [ ul [ class "inline" ] <| showPlatforms item.source.platforms ]
, dt [] [ text "Homepage" ]
, dd [] [ withDefault asLink item.source.homepage ]
, 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_position" (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

View file

@ -4,6 +4,7 @@ module Search exposing
, Options
, Result
, ResultItem
, channelDetailsFromId
, decodeResult
, init
, makeRequest
@ -221,11 +222,67 @@ createUrl path channel query showDetailsFor from size =
-- 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 :
String
-> String
-> Model a
-> (Maybe String -> Result a -> Html b)
-> (String -> Maybe String -> Result a -> Html b)
-> (Msg a -> b)
-> Html b
view path title model viewSuccess outMsg =
@ -249,16 +306,19 @@ view path title model viewSuccess outMsg =
[ text " in " ]
, select
[ onInput (\x -> outMsg (ChannelChange x)) ]
[ option
[ value "unstable" ]
[ text "unstable" ]
, option
[ value "20.03" ]
[ text "20.03" ]
, option
[ value "19.09" ]
[ text "19.09" ]
]
(List.filterMap
(\channel_id ->
channelDetailsFromId channel_id
|> Maybe.map
(\channel ->
option
[ value channel.id
]
[ text channel.title ]
)
)
channels
)
, strong []
[ text " channel." ]
]
@ -299,7 +359,7 @@ view path title model viewSuccess outMsg =
]
]
, viewPager outMsg model result path
, viewSuccess model.showDetailsFor result
, viewSuccess model.channel model.showDetailsFor result
, viewPager outMsg model result path
]

View file

@ -6,7 +6,7 @@ const {Elm} = require('./Main');
Elm.Main.init({
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',
elasticsearchUsername : process.env.ELASTICSEARCH_USERNAME || 'z3ZFJ6y2mR',
elasticsearchPassword : process.env.ELASTICSEARCH_PASSWORD || 'ds8CEvALPf9pui7XG'