summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2015-02-22 21:06:43 +0100
committerAlex Legler <alex@a3li.li>2015-02-22 21:06:43 +0100
commitb0086f9f9cb9be97d0cf2715330f57075ea843c0 (patch)
treeeafd8b075a93dc4e0a9c87630dfd899da15cf306 /lib
parentCache message counts (diff)
downloadfrontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.tar.gz
frontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.tar.bz2
frontend-b0086f9f9cb9be97d0cf2715330f57075ea843c0.zip
Move full archives list to a separate page
Diffstat (limited to 'lib')
-rw-r--r--lib/helpers.rb1
-rw-r--r--lib/index.rb20
2 files changed, 20 insertions, 1 deletions
diff --git a/lib/helpers.rb b/lib/helpers.rb
index 405975b..88b8f59 100644
--- a/lib/helpers.rb
+++ b/lib/helpers.rb
@@ -1,4 +1,3 @@
-require 'date'
require 'rinku'
require 'erb'
diff --git a/lib/index.rb b/lib/index.rb
index de3d4f0..3cc7537 100644
--- a/lib/index.rb
+++ b/lib/index.rb
@@ -24,6 +24,26 @@ def threads_in_month(list, year, month, page)
)
end
+def most_recent(list, n)
+ result = $es.search(
+ index: 'ml-' + list,
+ size: n,
+ body: {
+ sort: {
+ date: 'desc',
+ }
+ }
+ )
+
+ if result['hits']['total'] == 0
+ return []
+ else
+ return result['hits']['hits']
+ end
+rescue => e
+ []
+end
+
def messages_in_month(list, year, month, page)
$es.search(
index: 'ml-' + list,