Permalink
Browse files

load achievements from collection, lowered update threshold and incre…

…ased number of users to update in one batch
  • Loading branch information...
1 parent 3e82eac commit 196090f62bd5b38c256c5c71e68f00e0458186ab @yaph committed Mar 12, 2012
Showing with 4 additions and 14 deletions.
  1. +0 −1 README.md
  2. +1 −11 app.rb
  3. +3 −2 update.rb
View
@@ -14,7 +14,6 @@ db.users.find({}, {gh_login:1, updated_at:1}).sort({updated_at:1}).limit(10)
## TODOs
-* include all necessary CSS in iframe template
* Create dedicate Sinatra::Base app for badges and load only what is needed
* Move controller logic from github.rb to helpers.rb
* languagegraph
View
12 app.rb
@@ -197,17 +197,7 @@ def validate(params)
get '/iframe/:gh_login/achievements' do
validate(params)
- # FIXME cache achievements
- achievements = nil
- user = User.new(settings.db).get(params[:gh_login])
- if user
- repos = Repo.new(settings.db).get_user_repos(user)
- stats = Stats.new.get(repos)
- if stats
- user['stats'] = stats
- achievements = Achievements.new.set_user_achievements(user)['achievements']
- end
- end
+ user = settings.db.collection('achievements').find_one({ 'gh_login' => params[:gh_login] })
liquid :achievements_iframe, :layout => false, :locals => {
:user => user,
:badge_title => params[:badge_title] || 'show'
View
@@ -10,8 +10,9 @@
require PATH + '/stats.rb'
require PATH + '/achievements.rb'
-record_limit = 10
-lifetime = 604800 # 1 week in seconds
+record_limit = 20
+#lifetime = 604800 # 1 week in seconds
+lifetime = 172800 # 2 days in seconds
update_threshold = Time.now.utc - lifetime

0 comments on commit 196090f

Please sign in to comment.