Permalink
Browse files

fixed some naming conventions and updated Gemfile

  • Loading branch information...
scalabl3 committed Dec 14, 2012
1 parent 68ce61e commit 582a06453818ce541ea9a8d5765fcaef3c2c907e
View
@@ -5,7 +5,7 @@ gem 'rails', '3.2.9'
gem 'omniauth'
gem 'omniauth-twitter'
-gem 'couchbase', '>= 1.2.0.z.beta3'
+gem 'couchbase', '>= 1.2.0'
gem 'couchbase-model'
gem 'masonry-rails'
gem 'grackle'
@@ -37,7 +37,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.4.0)
- couchbase (1.2.0.z.beta5)
+ couchbase (1.2.0)
multi_json (~> 1.0)
yaji (~> 0.3.2)
couchbase-model (0.5.1)
@@ -49,7 +49,7 @@ GEM
json
mime-types
oauth
- haml (3.2.0.rc.1)
+ haml (3.2.0.rc.2)
tilt
hashie (1.2.0)
hike (1.2.1)
@@ -104,7 +104,7 @@ GEM
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
- rake (10.0.2)
+ rake (10.0.3)
rdoc (3.12)
json (~> 1.4)
ruby_parser (3.1.0)
@@ -1,7 +1,7 @@
require 'grackle'
require 'couchbase/model'
-class Tweet < Couchbase::Model
+class Tweets < Couchbase::Model
HIPSTER = "rbin"
attribute :doctype
@@ -17,11 +17,11 @@ def self.get_latest
tweets = client.statuses.user_timeline? :screen_name => HIPSTER # hit the API
tweets.each do |t|
created = DateTime.parse(t.created_at)
- tweet_id = t.id_str
+ tweet_id = t.id_str.to_i
# create the tweet if it doesn't already exist
- unless Tweet.exists?(["tweet_id=?", tweet_id])
- Tweet.create({:doctype => "tweet", :content => t.text, :tweet_id => tweet_id, :created => created.getutc.to_i })
- end
+ #unless Tweet.exists?(["tweet_id=?", tweet_id])
+ Tweets.create({:doctype => "tweet", :content => t.text, :tweet_id => tweet_id, :created => created.getutc.to_i })
+ #end
end
end
@@ -37,3 +37,5 @@ def self.client
end
end
+
+Tweets.ensure_design_document!
@@ -6,8 +6,9 @@
// http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-writing-map.html
function(doc, meta) {
+ // list tweets by id
if (doc.doctype == "tweet" && meta.type == "json") {
- emit(doc.tweet_id, null);
+ emit(doc.tweet_id, doc.content);
}
}
@@ -10,7 +10,7 @@ function(doc, meta) {
var dt = new Date(0);
dt.setUTCSeconds(doc.created);
da = dateToArray(dt);
- emit(dt, doc.content);
+ emit(da, doc.content);
}
}

0 comments on commit 582a064

Please sign in to comment.