From 6da092aee781fdd6371505d3155e8a056c6aa4ae Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Fri, 6 Mar 2015 16:11:34 -0500 Subject: [PATCH] quick and dirty, not thread safe, temporary stripe customers cache for stats --- app/stats.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/stats.rb b/app/stats.rb index 0bf80618..f3868a8b 100644 --- a/app/stats.rb +++ b/app/stats.rb @@ -36,7 +36,15 @@ get '/stats/?' do @stats[:monthly_stats] = monthly_stats - customers = Stripe::Customer.all limit: 100000 + if $stripe_cache && Time.now < $stripe_cache[:time] + 14400 + customers = $stripe_cache[:customers] + else + customers = Stripe::Customer.all limit: 100000 + $stripe_cache = { + customers: customers, + time: Time.now + } + end @stats[:monthly_revenue] = 0.0