Skip to content

Commit

Permalink
fix sort
Browse files Browse the repository at this point in the history
  • Loading branch information
satococoa committed Jul 10, 2011
1 parent d5d2597 commit 43136fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app.rb
Expand Up @@ -56,14 +56,14 @@ def get_tweets_from_api(hashtag)
else
tweets = search.since_id(since_id).fetch
end
if tweets.size > 1
if tweets.size > 0
REDIS.set "timestamp:#{hashtag}", Time.now.to_i
REDIS.set "last_id:#{hashtag}", tweets.first.id
# 最新10件を保持
tweets.each do |tweet|
REDIS.lpush "tweets:#{hashtag}", tweet.to_json
tweets.reverse.each do |tweet|
REDIS.rpush "tweets:#{hashtag}", tweet.to_json
end
REDIS.ltrim "tweets:#{hashtag}", 0, 9
REDIS.ltrim "tweets:#{hashtag}", -10, -1
end
end
def transform(tweets)
Expand Down

0 comments on commit 43136fe

Please sign in to comment.