diff --git a/boris-http/src/Boris/Http/Html/Template.hs b/boris-http/src/Boris/Http/Html/Template.hs index 6e9621b..885e89a 100644 --- a/boris-http/src/Boris/Http/Html/Template.hs +++ b/boris-http/src/Boris/Http/Html/Template.hs @@ -84,14 +84,18 @@ project p bs = builds :: Project -> Build -> [(Ref, [BuildId])] -> [BuildId] -> Either BMXError Text builds p b rs queued = let - prepped :: [(Text, BMXValue)] - prepped = - fmap (\(r, is) -> (renderRef r, BMXList $ (BMXString . renderBuildId) <$> sortBuildIds is)) rs + sorted = + reverse $ sortOn (\(_, is) -> head . sortBuildIds $ is) rs + + toRef r is = [ + ("name", BMXString $ renderRef r) + , ("builds", BMXList $ (BMXString . renderBuildId) <$> sortBuildIds is) + ] context = [ ("project", BMXString (renderProject p)) , ("build", BMXString (renderBuild b)) - , ("refs", BMXContext prepped) + , ("refs", BMXList $ fmap (BMXContext . uncurry toRef) sorted) , ("queued", BMXList ((BMXString . renderBuildId) <$> sortBuildIds queued)) ] in diff --git a/boris-http/template/builds.hbs b/boris-http/template/builds.hbs index 8b4ff7b..aea111b 100644 --- a/boris-http/template/builds.hbs +++ b/boris-http/template/builds.hbs @@ -25,11 +25,11 @@ {{/each}} {{/if}} - {{#each refs as |key val|}} + {{#each refs}}
-

{{key}}

+

{{this.name}}

- {{#each val}} + {{#each this.builds}} #{{this}}