You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2017/09/06 12:21:47 UTC

[whimsy] 01/02: cache index

This is an automated email from the ASF dual-hosted git repository.

rubys pushed a commit to branch roster_on_vue
in repository https://gitbox.apache.org/repos/asf/whimsy.git

commit f9179099cf8692b3ce02a5947a4d4ded6beb436a
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Wed Sep 6 08:20:34 2017 -0400

    cache index
---
 www/roster/main.rb | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/www/roster/main.rb b/www/roster/main.rb
index 942f634..8925dae 100755
--- a/www/roster/main.rb
+++ b/www/roster/main.rb
@@ -54,17 +54,27 @@ get '/committee' do
   redirect to('/committee/')
 end
 
+@index = nil
+@index_time = nil
 get '/committer/index.json' do
-  # bulk loading the mail information makes things go faster
-  mail = Hash[ASF::Mail.list.group_by(&:last).
-    map {|person, list| [person, list.map(&:first)]}]
-
-  # return a list of people, their public-names, and email addresses
-  ASF::Person.list.sort_by(&:id).map {|person|
-    result = {id: person.id, name: person.public_name, mail: mail[person]}
-    result[:member] = true if person.asf_member?
-    result
-  }.to_json
+  @index = nil unless @index_time and Time.now-@index_tine < 300
+
+  if not @index
+    # bulk loading the mail information makes things go faster
+    mail = Hash[ASF::Mail.list.group_by(&:last).
+      map {|person, list| [person, list.map(&:first)]}]
+
+    # return a list of people, their public-names, and email addresses
+    @index = ASF::Person.list.sort_by(&:id).map {|person|
+      result = {id: person.id, name: person.public_name, mail: mail[person]}
+      result[:member] = true if person.asf_member?
+      result
+    }
+  end
+
+  _json do
+    @index
+  end
 end
 
 get '/committee/:name.json' do |name|

-- 
To stop receiving notification emails like this one, please contact
"commits@whimsical.apache.org" <co...@whimsical.apache.org>.