activity_feed 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +2 -0
- data/lib/activity_feed/feed.rb +18 -0
- data/lib/activity_feed/version.rb +1 -1
- data/spec/activity_feed/feed_spec.rb +17 -41
- data/spec/version_spec.rb +1 -1
- metadata +4 -4
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 2.2.0 (2012-08-20)
|
4
|
+
|
5
|
+
* Added `expire_feed(user_id, seconds, aggregate = ActivityFeed.aggregate)` and `expire_feed_at(user_id, timestamp, aggregate = ActivityFeed.aggregate)` methods to expire an activity feed after a given number of seconds or at a given time stamp, respectively.
|
6
|
+
|
3
7
|
## 2.1.0 (2012-08-13)
|
4
8
|
|
5
9
|
* Added `full_feed(user_id, aggregate = ActivityFeed.aggregate)` method to be able to retrieve an entire activity feed
|
data/README.markdown
CHANGED
@@ -293,6 +293,8 @@ ActivityFeed.feed_between_timestamps(user_id, starting_timestamp, ending_timesta
|
|
293
293
|
ActivityFeed.total_pages_in_feed(user_id, aggregate = ActivityFeed.aggregate, page_size = ActivityFeed.page_size)
|
294
294
|
ActivityFeed.total_items_in_feed(user_id, aggregate = ActivityFeed.aggregate)
|
295
295
|
ActivityFeed.trim_feed(user_id, starting_timestamp, ending_timestamp, aggregate = ActivityFeed.aggregate)
|
296
|
+
ActivityFeed.expire_feed(user_id, seconds, aggregate = ActivityFeed.aggregate)
|
297
|
+
ActivityFeed.expire_feed_at(user_id, timestamp, aggregate = ActivityFeed.aggregate)
|
296
298
|
ActivityFeed.remove_feeds(user_id)
|
297
299
|
```
|
298
300
|
|
data/lib/activity_feed/feed.rb
CHANGED
@@ -119,5 +119,23 @@ module ActivityFeed
|
|
119
119
|
def trim_feed(user_id, starting_timestamp, ending_timestamp, aggregate = ActivityFeed.aggregate)
|
120
120
|
ActivityFeed.feederboard_for(user_id, aggregate).remove_members_in_score_range(starting_timestamp, ending_timestamp)
|
121
121
|
end
|
122
|
+
|
123
|
+
# Expire an activity feed after a set number of seconds.
|
124
|
+
#
|
125
|
+
# @param user_id [String] User ID.
|
126
|
+
# @param seconds [int] Number of seconds after which the activity feed will be expired.
|
127
|
+
# @param aggregate [boolean, false] Whether or not to expire the aggregate activity feed or not.
|
128
|
+
def expire_feed(user_id, seconds, aggregate = ActivityFeed.aggregate)
|
129
|
+
ActivityFeed.redis.expire(ActivityFeed.feed_key(user_id, aggregate), seconds)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Expire an activity feed at a given timestamp.
|
133
|
+
#
|
134
|
+
# @param user_id [String] User ID.
|
135
|
+
# @param timestamp [int] Timestamp after which the activity feed will be expired.
|
136
|
+
# @param aggregate [boolean, false] Whether or not to expire the aggregate activity feed or not.
|
137
|
+
def expire_feed_at(user_id, timestamp, aggregate = ActivityFeed.aggregate)
|
138
|
+
ActivityFeed.redis.expireat(ActivityFeed.feed_key(user_id, aggregate), timestamp)
|
139
|
+
end
|
122
140
|
end
|
123
141
|
end
|
@@ -242,52 +242,28 @@ describe ActivityFeed::Feed do
|
|
242
242
|
feed[0].should == item
|
243
243
|
end
|
244
244
|
end
|
245
|
+
end
|
245
246
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
begin
|
250
|
-
ActivityFeed::Mongoid::Item.find(id)
|
251
|
-
rescue Mongoid::Errors::DocumentNotFound
|
252
|
-
end
|
253
|
-
end
|
247
|
+
describe '#expire_feed' do
|
248
|
+
it 'should set an expiration on an activity feed' do
|
249
|
+
add_items_to_feed('david', Leaderboard::DEFAULT_PAGE_SIZE)
|
254
250
|
|
255
|
-
|
256
|
-
|
257
|
-
|
251
|
+
ActivityFeed.expire_feed('david', 10)
|
252
|
+
ActivityFeed.redis.ttl(ActivityFeed.feed_key('david')).tap do |ttl|
|
253
|
+
ttl.should be > 1
|
254
|
+
ttl.should be <= 10
|
258
255
|
end
|
256
|
+
end
|
257
|
+
end
|
259
258
|
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
ActivityFeed::Mongoid::Item.find(id)
|
264
|
-
rescue Mongoid::Errors::DocumentNotFound
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
268
|
-
item = ActivityFeed::Mongoid::Item.create(
|
269
|
-
:user_id => 'david',
|
270
|
-
:nickname => 'David Czarnecki',
|
271
|
-
:type => 'some_activity',
|
272
|
-
:title => 'Great activity',
|
273
|
-
:text => 'This is text for the feed item',
|
274
|
-
:url => 'http://url.com'
|
275
|
-
)
|
276
|
-
|
277
|
-
ActivityFeed.update_item('david', '4fe4c5f3421aa9b89c000001', DateTime.now.to_i)
|
278
|
-
|
279
|
-
another_item = ActivityFeed::Mongoid::Item.create(
|
280
|
-
:user_id => 'david',
|
281
|
-
:nickname => 'David Czarnecki',
|
282
|
-
:type => 'some_activity',
|
283
|
-
:title => 'Great activity',
|
284
|
-
:text => 'This is more text for the feed item',
|
285
|
-
:url => 'http://url.com'
|
286
|
-
)
|
287
|
-
|
288
|
-
feed = ActivityFeed.feed('david', 1)
|
259
|
+
describe '#expire_feed_at' do
|
260
|
+
it 'should set an expiration timestamp on an activity feed' do
|
261
|
+
add_items_to_feed('david', Leaderboard::DEFAULT_PAGE_SIZE)
|
289
262
|
|
290
|
-
|
263
|
+
ActivityFeed.expire_feed_at('david', (Time.now + 10).to_i)
|
264
|
+
ActivityFeed.redis.ttl(ActivityFeed.feed_key('david')).tap do |ttl|
|
265
|
+
ttl.should be > 1
|
266
|
+
ttl.should be <= 10
|
291
267
|
end
|
292
268
|
end
|
293
269
|
end
|
data/spec/version_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activity_feed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -215,7 +215,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
215
|
version: '0'
|
216
216
|
segments:
|
217
217
|
- 0
|
218
|
-
hash: -
|
218
|
+
hash: -3462149266482733398
|
219
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
220
|
none: false
|
221
221
|
requirements:
|
@@ -224,7 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
224
|
version: '0'
|
225
225
|
segments:
|
226
226
|
- 0
|
227
|
-
hash: -
|
227
|
+
hash: -3462149266482733398
|
228
228
|
requirements: []
|
229
229
|
rubyforge_project: activity_feed
|
230
230
|
rubygems_version: 1.8.24
|