From 130827d8abc0794b8496b06dc836303a35bc443e Mon Sep 17 00:00:00 2001 From: Alex Legler Date: Sat, 14 Mar 2015 13:02:03 +0100 Subject: Explicitly sort IDs --- anzen.rb | 6 +++--- lib/glsa_repository.rb | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/anzen.rb b/anzen.rb index 655e7de..86dca94 100644 --- a/anzen.rb +++ b/anzen.rb @@ -24,13 +24,13 @@ GLSARepository.instance BASE_URL = 'https://security.gentoo.org/'.freeze get '/glsa/?' do - @ids = GLSARepository.instance.get.keys.reverse + @ids = GLSARepository.instance.latest_ids @nav = :glsa erb :glsa end get '/glsa/feed.:format' do - items = GLSARepository.instance.get.values.reverse[0..50] + items = GLSARepository.instance.latest 50 case params[:format] when 'atom' content_type :atom @@ -87,7 +87,7 @@ get '/subscribe' do end get '/' do - @ids = GLSARepository.instance.get.keys.reverse + @ids = GLSARepository.instance.latest_ids @nav = :index erb :index end diff --git a/lib/glsa_repository.rb b/lib/glsa_repository.rb index 90c9899..ee1096b 100644 --- a/lib/glsa_repository.rb +++ b/lib/glsa_repository.rb @@ -32,12 +32,21 @@ class GLSARepository @load_date = DateTime.now @advisories = advisories.freeze + @latest = advisories.keys.sort.reverse.freeze end def get @advisories end + def latest_ids + @latest + end + + def latest(n = 10) + @latest[0..n].map {|id| @advisories[id] } + end + def[](id) @advisories[id] end -- cgit v1.2.3-65-gdbad