Skip to content

Commit

Permalink
Merge pull request #119 from ambiata/topic/ref-sorting
Browse files Browse the repository at this point in the history
Sort refs by latest build.
  • Loading branch information
markhibberd authored Aug 30, 2016
2 parents 9f14914 + 8620361 commit eb736d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions boris-http/src/Boris/Http/Html/Template.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions boris-http/template/builds.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
{{/each}}
</div>
{{/if}}
{{#each refs as |key val|}}
{{#each refs}}
<div>
<h4>{{key}}</h4>
<h4>{{this.name}}</h4>
<div>
{{#each val}}
{{#each this.builds}}
<span>
<a href="/build/{{this}}">#{{this}}</a>
</span>
Expand Down

0 comments on commit eb736d8

Please sign in to comment.