From 86203619345364ed6d4b53feda27297092c0ba37 Mon Sep 17 00:00:00 2001 From: mth Date: Tue, 30 Aug 2016 19:06:35 +1000 Subject: [PATCH] Sort refs by lastest build. --- boris-http/src/Boris/Http/Html/Template.hs | 12 ++++++++---- boris-http/template/builds.hbs | 6 +++--- 2 files changed, 11 insertions(+), 7 deletions(-) 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}}