diff options
-rw-r--r-- | lib/index.rb | 9 | ||||
-rw-r--r-- | views/index.erb | 21 |
2 files changed, 20 insertions, 10 deletions
diff --git a/lib/index.rb b/lib/index.rb index a50ba4c..5690afe 100644 --- a/lib/index.rb +++ b/lib/index.rb @@ -73,6 +73,15 @@ def get_month_listing(list) ) end +def get_message_count(list) + $es.search( + index: 'ml-' + list, + size: 1, + body: {} + )['hits']['total'] +rescue => e + '?' +end def get_message(list, hash) $es.search( diff --git a/views/index.erb b/views/index.erb index 77eda4c..d1454ea 100644 --- a/views/index.erb +++ b/views/index.erb @@ -6,7 +6,11 @@ <div class="col-xs-12 col-md-6"> <div class="list-group"> <% $config['active_lists'].each do |list| %> - <a href="<%= h list %>/" class="list-group-item"><span class="fa fa-fw fa-archive"></span> <%= h list %></a> + <a href="<%= h list %>/" class="list-group-item"> + <span class="fa fa-fw fa-archive"></span> + <%= h list %> + <span class="badge"><%= get_message_count(list) %></span> + </a> <% end %> </div> </div> @@ -24,15 +28,12 @@ <div class="row"> <div class="col-xs-12 col-md-6"> <div class="list-group"> - <% $config['frozen_lists'].each do |list| - begin - months = get_month_listing(list) - count = months['hits']['total'] + ' mails' - rescue => e - count = 'mail count unavailable' - end - %> - <a href="<%= h list %>/" class="list-group-item"><span class="fa fa-fw fa-archive"></span> <%= h list %> (<%= count %>)</a> + <% $config['frozen_lists'].each do |list| %> + <a href="<%= h list %>/" class="list-group-item"> + <span class="fa fa-fw fa-archive"></span> + <%= h list %> + <span class="badge"><%= get_message_count(list) %></span> + </a> <% end %> </div> </div> |