Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bscofield committed Nov 10, 2010
1 parent 486679c commit 1b7acd4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/controllers/tweets_controller.rb
@@ -1,5 +1,5 @@
class TweetsController < ApplicationController
def index
@docs = Tweet.search(params[:query]) if params[:query].present?
@docs = TweetIndexer.search(params[:query]) if params[:query].present?
end
end
24 changes: 18 additions & 6 deletions app/models/tweet.rb
Expand Up @@ -3,17 +3,29 @@ def initialize(data)
@data = data
end

def id
@data['Id']
end

def to_document
{
:plixi_id => @data['Id'],
:text => @data['Message'],
:timestamp => @data['UploadDate'].to_i,
:screen_name => @data['ScreenName'],
:thumbnail_url => @data['ThumbnailUrl']
:plixi_id => self.id,
:text => self.message,
:timestamp => self.upload_date.to_i,
:screen_name => self.screen_name,
:thumbnail_url => self.thumbnail_url
}
end

def indexable?
@data['Message'].present?
self.message.present?
end

def method_missing(name, *args, &block)
if @data[name.to_s.classify]
@data[name.to_s.classify]
else
super
end
end
end
2 changes: 1 addition & 1 deletion app/models/tweet_indexer.rb
@@ -1,5 +1,5 @@
require 'open-uri'
require 'lib/indextank_client'
require 'indextank_client'

class TweetIndexer
def self.index
Expand Down

0 comments on commit 1b7acd4

Please sign in to comment.