Class: Flamingo::Stats::Connection
- Inherits:
-
Object
- Object
- Flamingo::Stats::Connection
- Defined in:
- lib/flamingo/stats/connection.rb
Constant Summary collapse
- START_TIME =
"conn:start:time"
- START_EVENT_COUNT =
"conn:start:event_count"
- START_TWEET_COUNT =
"conn:start:tweet_count"
- LIMIT_COUNT =
"conn:limit:count"
- LIMIT_TIME =
"conn:limit:time"
- COVERAGE =
"conn:coverage"
Instance Method Summary collapse
- #connected! ⇒ Object
- #coverage_rate ⇒ Object
- #event_stats ⇒ Object
- #limited!(count) ⇒ Object
- #meta ⇒ Object
- #received_events ⇒ Object
- #received_tweets ⇒ Object
- #skipped_tweets ⇒ Object
Instance Method Details
#connected! ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/flamingo/stats/connection.rb', line 12 def connected! .set(START_TIME,Time.now.to_i) .set(START_EVENT_COUNT,event_stats.all_count) .set(START_TWEET_COUNT,event_stats.tweet_count) .set(COVERAGE,100) .delete(LIMIT_COUNT) .delete(LIMIT_TIME) end |
#coverage_rate ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/flamingo/stats/connection.rb', line 39 def coverage_rate received = received_tweets possible_tweets = received + skipped_tweets if possible_tweets == 0 0 else (received / possible_tweets.to_f)*100 end end |
#event_stats ⇒ Object
53 54 55 |
# File 'lib/flamingo/stats/connection.rb', line 53 def event_stats Flamingo.event_stats end |
#limited!(count) ⇒ Object
21 22 23 24 25 |
# File 'lib/flamingo/stats/connection.rb', line 21 def limited!(count) .set(LIMIT_COUNT,count) .set(LIMIT_TIME,Time.now.to_i) .set(COVERAGE,coverage_rate) end |
#meta ⇒ Object
49 50 51 |
# File 'lib/flamingo/stats/connection.rb', line 49 def Flamingo. end |
#received_events ⇒ Object
35 36 37 |
# File 'lib/flamingo/stats/connection.rb', line 35 def received_events event_stats.all_count - (.get(START_EVENT_COUNT) || 0) end |
#received_tweets ⇒ Object
27 28 29 |
# File 'lib/flamingo/stats/connection.rb', line 27 def received_tweets event_stats.tweet_count - (.get(START_TWEET_COUNT) || 0) end |
#skipped_tweets ⇒ Object
31 32 33 |
# File 'lib/flamingo/stats/connection.rb', line 31 def skipped_tweets .get(LIMIT_COUNT) || 0 end |