Refactor the / route

This commit is contained in:
Alex Ling 2020-05-19 12:16:32 +00:00
parent ff6e64f12a
commit c35e840694

View File

@ -68,11 +68,12 @@ class MainRouter < Router
titles = @context.library.titles titles = @context.library.titles
username = get_username env username = get_username env
on_deck_entries = [] of Entry # map: get the on-deck entry or nil for each Title
titles.each do |title| # select: select only entries (and ignore Nil's) from the array
on_deck_entry = title.get_on_deck_entry username # produced by map
on_deck_entries << on_deck_entry if on_deck_entry # ingnore titles without latest on deck entry on_deck_entries = titles.map { |t|
end t.get_on_deck_entry username
}.select Entry
layout "home" layout "home"
rescue e rescue e