easy_admin 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog for easy-admin
2
+
3
+ ## 0.2.0 (2013-08-12)
4
+
5
+ New Features:
6
+
7
+ * Added OutboundRequest#rpm method that returns the number of requests per minute for the supplied criteria
@@ -45,4 +45,19 @@ class OutboundRequest < ActiveRecord::Base
45
45
  def elapsed_time
46
46
  updated_at - created_at
47
47
  end
48
+
49
+ def self.rpm(params={})
50
+ period = params[:period] || 60 # period in seconds
51
+ mins_per_period = period / 60.0
52
+
53
+ query = where('created_at > ?', Time.current - period.seconds)
54
+
55
+ [:service, :action, :response_code].each do |filter|
56
+ if params[filter]
57
+ query = query.where(filter => params[filter])
58
+ end
59
+ end
60
+
61
+ query.count / mins_per_period
62
+ end
48
63
  end
@@ -1,3 +1,3 @@
1
1
  module EasyAdmin
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
Binary file