<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,7 +5,10 @@ class Admin::PeopleController &lt; ApplicationController
   
   def index    
     @page_title = t('people_admin')
-    @people = Person.paginate(params)
+    opts = { :page =&gt; params[:page], :order =&gt; 'users.followers_count DESC', :include =&gt; :user }
+    opts[:order] = params[:sort] unless params[:sort].blank?
+    opts[:conditions] = [&quot;concat(people.first_name, ' ', people.last_name) like ? or concat(people.nickname, ' ', people.last_name) like ?&quot;, &quot;%#{params[:q]}%&quot;,&quot;%#{params[:q]}%&quot;] unless params[:q].blank?
+    @people = Person.paginate opts
     
     render :layout =&gt; false if request.xhr?
   end
@@ -55,6 +58,6 @@ class Admin::PeopleController &lt; ApplicationController
   
   protected
     def find_person
-      @person = Person.get(params[:id])
+      @person = Person.find(params[:id])
     end
 end</diff>
      <filename>app/controllers/admin/people_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,19 +2,23 @@ class MainController &lt; ApplicationController
   
   def index
     @page_title = t('home_title')
-    @tweets = TwitterStatus.paginate(params)
+    opts = {:page =&gt; params[:page], :order =&gt; 'statuses.id DESC', :include =&gt; :user}
+    @tweets = Status.paginate opts
   end
   
   def tweetstream
     @page_title = t('tweetstream')
-    @tweets = TwitterStatus.paginate(params)
+    opts = {:page =&gt; params[:page], :order =&gt; 'statuses.id DESC', :include =&gt; :user}
+    opts[:conditions] = [&quot;statuses.text like ?&quot;, &quot;%#{params[:q]}%&quot;] unless params[:q].blank?
+    @tweets = Status.paginate opts
   end
   
   def stats
-    @most_followed = Person.all.sort_by{|p| p.followers_count.to_i}.reverse[0..4]
-    @most_active = Person.all.sort_by{|p| p.statuses_count.to_i}.reverse[0..4]
-    @most_new_seven_days = Person.most_followers_last_seven_days
-    @most_new_thirty_days = Person.most_followers_last_thirty_days
+    @most_followed = Person.all :include =&gt; :user, :order =&gt; 'users.followers_count desc', :limit =&gt; 5 
+    @most_active = Person.all :include =&gt; :user, :order =&gt; 'users.statuses_count desc', :limit =&gt; 5 
+    
+    @most_new_seven_days = Person.all(:include =&gt; {:user =&gt; :stats}, :order =&gt; 'stats.followers_change_last_seven_days desc', :limit =&gt; 5).map{|p| [p, p.user.stats.followers_change_last_seven_days]}
+    @most_new_thirty_days = Person.all(:include =&gt; {:user =&gt; :stats}, :order =&gt; 'stats.followers_change_last_thirty_days desc', :limit =&gt; 5).map{|p| [p, p.user.stats.followers_change_last_thirty_days]}
   end
   
   protected</diff>
      <filename>app/controllers/main_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,22 +4,16 @@ class PeopleController &lt; ApplicationController
   
   def index
     @page_title = t('people')
-    @people = Person.paginate(params)
-    @reverse = params[:reverse]
-    @sort_attribute = params[:sort]
-    begin
-      #@twitter_base ||= Twitter::Base.new('foo', 'bar')
-    rescue
-    end
-    
+    opts = { :page =&gt; params[:page], :order =&gt; 'users.followers_count DESC', :include =&gt; :user }
+    opts[:order] = params[:sort] unless params[:sort].blank?
+    opts[:conditions] = [&quot;concat(people.first_name, ' ', people.last_name) like ? or concat(people.nickname, ' ', people.last_name) like ?&quot;, &quot;%#{params[:q]}%&quot;,&quot;%#{params[:q]}%&quot;] unless params[:q].blank?
+    @people = Person.paginate opts
   end
   
 
   def show
     if @person.tweets?
       @page_title = t('person_is_on_twitter', :name =&gt; @person.display_name)
-      @tweets = TwitterStatus.paginate(params.merge({:screen_names =&gt; @person.screen_name}))
-      
     else
       @page_title = t('person_is_on_not_twitter', :name =&gt; @person.display_name)
     end
@@ -28,15 +22,9 @@ class PeopleController &lt; ApplicationController
   
   def follow
     if @person and @person.tweets?
-      begin
-        #twitter_response = JSON.parse(current_user.twitter.post(&quot;http://twitter.com/friendships/create/#{@person.screen_name}.json&quot;))
-        twitter_response = current_user.twitter.post(&quot;http://twitter.com/friendships/create/#{@person.screen_name}.json&quot;)
-        flash[:notice] = t('you_are_now_following', :name =&gt; @person.screen_name)
-      rescue Exception =&gt; ex
-        flash[:notice] = ex.message
-      end
+      twitter_response = JSON.parse(current_user.twitter.post(&quot;http://twitter.com/friendships/create/#{@person.screen_name}.json&quot;))
+      flash[:notice] = t('you_are_now_following', :name =&gt; @person.screen_name)
     end
-    redirect_to people_url
   end
   
   def follow_all
@@ -45,7 +33,10 @@ class PeopleController &lt; ApplicationController
   
   protected
     def find_person
-      @person = Person.get(params[:id])
+      @person = Person.find(params[:id])
+      opts = {:page =&gt; params[:page], :order =&gt; 'statuses.id DESC', :include =&gt; :user}
+      opts[:conditions] = [&quot;statuses.text like ?&quot;, &quot;%#{params[:q]}%&quot;] unless params[:q].blank?
+      @tweets = @person.user.statuses.paginate opts
     end
 
 end</diff>
      <filename>app/controllers/people_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -21,7 +21,7 @@ module FloxeeHelper
   end
   
   def twitter_status_path(status)
-    &quot;http://twitter.com/#{status.from_user}/statuses/#{status.id}&quot;
+    &quot;http://twitter.com/#{status.user.screen_name}/status/#{status.id}&quot;
   end
   
   def twitter_profile_image(twitter_user, options={})
@@ -42,6 +42,16 @@ module FloxeeHelper
     image_tag(user_profile_image_path(size), options)
   end
   
+  def detail_link_for_tweet(tweet)
+    if tweet.person
+      link_to tweet.person.display_name, person_path(tweet.person)
+    elsif tweet.organization
+      link_to tweet.organization.display_name, organization_path(tweet.organization)
+    else
+      link_to tweet.user.screen_name, twitter_user_url(tweet.user.screen_name)
+    end
+  end
+  
   def icon(filename)
     image_tag('/images/icons/fugue/' + filename + '.png')
   end</diff>
      <filename>app/helpers/floxee_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,183 +1,22 @@
-class Person &lt; CouchRest::ExtendedDocument
-  use_database CouchRest.database!(Floxee.server)
-  
-  include CouchRest::Validation
-  
-  #save_callback :before, :generate_slug_from_name
-  save_callback :before, :fetch_info
-  save_callback :after, :fetch_stats
-  save_callback :after, :fetch_latest_statuses
-  
-  unique_id do |contact|
-    # TODO: Make this a recursive method to guarantee uniqueness
-    contact.generate_unique_id
-  end
-  
-  property :title
-  property :first_name
-  property :middle_name
-  property :last_name
-  property :nickname
-  property :name_suffix
-  property :gender
-  property :email
-  property :website
-  property :phone
-  property :fax
-  
-  # twitter api properties
-  property :name
-  property :screen_name
-  property :location
-  property :description
-  property :profile_image_url
-  property :url
-  property :protected
-  property :followers_count
-  property :profile_background_color
-  property :profile_text_color
-  property :profile_link_color
-  property :profile_sidebar_fill_color
-  property :profile_sidebar_border_color
-  property :friends_count
-  property :favourites_count
-  property :utc_offset
-  property :statuses_count
-  
-  timestamps!
-  
-  validates_present :first_name, :last_name
-  
-  view_by :id, :descending =&gt; true
-  view_by :screen_name
-  view_by :last_name
+class Person &lt; ActiveRecord::Base
+  belongs_to :user
   
+  delegate :followers_count, :friends_count, :statuses_count, :profile_image_url, :description, :to =&gt; :user
   
   def display_name
-    &quot;#{self.first_name} #{self.last_name}&quot;
+    &quot;#{nickname.blank? ? first_name : nickname} #{last_name}&quot;
   end
   
-  def id_ordinal
-    self.id.gsub(self.display_name.to_url,&quot;&quot;).gsub(&quot;-&quot;, &quot;&quot;).to_i
-  end
   
-  def tweets?
-    not self.screen_name.blank?
-  end
-  
-  def stats
-     TwitterUserStats.by_screen_name(:key =&gt; self.screen_name).first
-  end
-
-  def fetch_info
-    unless self.screen_name.nil?
-      begin
-        user = JSON.parse(Net::HTTP.get(URI.parse(&quot;http://twitter.com/users/show/#{self.screen_name}.json&quot;)))
-        self.merge!(user) if user
-      rescue
-        puts &quot;Problem getting Twitter info for #{self.display_name}&quot;
-      end
-    end
+  def screen_name=(value)
+    self.user = User.find_or_create_by_screen_name(value)
   end
   
-  def fetch_stats
-    unless self.screen_name.nil?
-      begin
-      stats = TwitterUserStats.by_screen_name(:key =&gt; self.screen_name).first
-        if stats
-          stats.destroy
-        else
-          stats = TwitterUserStats.new
-          stats.screen_name = self.screen_name
-        end
-        stats.save
-      rescue
-        puts &quot;Problem getting TwitterCounter stats for #{self.display_name}&quot;
-      end
-    end
+  def screen_name
+    self.user.screen_name unless self.user.blank?
   end
   
-  def statuses
-    TwitterStatus.by_from_user(:key =&gt; self.screen_name)
-  end
-  
-  def fetch_latest_statuses
-    unless self.screen_name.nil?
-      begin
-        if self.statuses.blank?
-          # self.statuses = []
-          # multiple calls to get all statuses
-          page_count = (self.statuses_count/100) + 1
-          (1..(page_count)).each do |page|
-            search = Twitter::Search.new.from(self.screen_name).page(page).per_page(100).fetch()
-            #self.statuses.concat search['results']
-            search['results'].each do |tweet|
-              ts = TwitterStatus.new(tweet)
-              ts.person_id = self.id
-              ts.save
-            end
-          end      
-        else
-          last_id = self.statuses.map{|status| status.id}.max
-          search = Twitter::Search.new.from(self.screen_name).since(last_id).fetch()
-          #self.statuses.concat(search['results']).uniq!      
-          search['results'].each do |tweet|
-            ts = TwitterStatus.new(tweet)
-            ts.person_id = self.id
-            ts.save
-          end
-        end
-        # Refresh the TwitterStatus cache if new results are returned
-        TwitterStatus.cached_by_id(true) if search['results'].size &gt; 0
-      rescue
-        puts &quot;Problem getting tweets for #{self.display_name}&quot;
-      end
-    end
-  end
-  
-  def self.paginate(options={})
-    options[:sort] ||= 'last_name'
-    
-    options[:per_page] ||= 10
-    options[:page] ||= 1
-     
-    options[:per_page] = options[:per_page].to_i
-    options[:page] = options[:page].to_i
-    
-    if %w{statuses_count followers_count}.include?(options[:sort])
-      @people = Person.search(options).sort_by{|p| p[options[:sort]].to_i}
-    else
-      @people = Person.search(options).sort_by{|p| p[options[:sort]].to_s}
-    end
-    @people.reverse! unless (options[:reverse].to_s == &quot;true&quot; or options[:reverse].blank?)
-    @people.paginate(:page =&gt; options[:page], :per_page =&gt; options[:per_page])
-  end
-  
-  def self.search(options={})
-    @people = Rails.cache.fetch('people', :expires_in =&gt; 60*60*6) {Person.all}
-    @people = @people.select{|p| p.display_name.downcase.include?(options[:q]) } unless options[:q].blank?
-    @people
-  end
-  
-  def self.most_followers_last_seven_days
-    people_with_stats =  Person.all.select{|p| !p.stats.nil?}
-    people_with_stats.sort_by{|p| p.stats.followers_change_last_seven_days.to_i}.reverse[0..9].map{|p| [p, p.stats.followers_change_last_seven_days]}
-  end
-  
-  def self.most_followers_last_thirty_days
-    people_with_stats =  Person.all.select{|p| !p.stats.nil?}
-    people_with_stats.sort_by{|p| p.stats.followers_change_last_thirty_days.to_i}.reverse[0..9].map{|p| [p, p.stats.followers_change_last_thirty_days]}
-  end
-
-  def generate_unique_id
-    unique_id = self.display_name.to_url
-    people = Person.all.select {|person| person.id.include?(unique_id)}
-    if people.empty?
-      unique_id
-    else
-      max_ordinal = people.map {|person| person.id_ordinal}.max
-      unique_id + &quot;-&quot; + (max_ordinal + 1).to_s
-    end
+  def tweets?
+    not self.user.nil?
   end
-  
-end
\ No newline at end of file
+end</diff>
      <filename>app/models/person.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,55 +1,102 @@
-require 'digest/sha1'
-
-class User &lt; ActiveRecord::Base
-  include Authentication
-  include Authentication::ByPassword
-  include Authentication::ByCookieToken
-
-  validates_presence_of     :login
-  validates_length_of       :login,    :within =&gt; 3..40
-  validates_uniqueness_of   :login
-  validates_format_of       :login,    :with =&gt; Authentication.login_regex, :message =&gt; Authentication.bad_login_message
-
-  validates_format_of       :name,     :with =&gt; Authentication.name_regex,  :message =&gt; Authentication.bad_name_message, :allow_nil =&gt; true
-  validates_length_of       :name,     :maximum =&gt; 100
-
-  validates_presence_of     :email
-  validates_length_of       :email,    :within =&gt; 6..100 #r@a.wk
-  validates_uniqueness_of   :email
-  validates_format_of       :email,    :with =&gt; Authentication.email_regex, :message =&gt; Authentication.bad_email_message
+class User &lt; TwitterAuth::GenericUser
+  # Extend and define your user model as you see fit.
+  # All of the authentication logic is handled by the 
+  # parent TwitterAuth::GenericUser class.
 
+  has_one :stats, :class_name =&gt; &quot;Stats&quot;
+  has_many :daily_stats, :class_name =&gt; &quot;DailyStats&quot;, :order =&gt; 'report_date ASC'
+  has_many :statuses, :order =&gt; 'id DESC'
   
-
-  # HACK HACK HACK -- how to do attr_accessible from here?
-  # prevents a user from submitting a crafted form that bypasses activation
-  # anything else you want your user to change should be added here.
-  attr_accessible :login, :email, :name, :password, :password_confirmation
-
-
-
-  # Authenticates a user by their login name and unencrypted password.  Returns the user or nil.
-  #
-  # uff.  this is really an authorization, not authentication routine.  
-  # We really need a Dispatch Chain here or something.
-  # This will also let us return a human error message.
-  #
-  def self.authenticate(email, password)
-    return nil if email.blank? || password.blank?
-    u = find_by_login(email.downcase) # need to get the salt
-    u = find_by_email(email.downcase) if u.nil?
-    u &amp;&amp; u.authenticated?(password) ? u : nil
+  named_scope :synced, :conditions =&gt; ['last_synced_at IS NOT NULL']
+  
+  
+  def screen_name
+    self.login
   end
-
-  def login=(value)
-    write_attribute :login, (value ? value.downcase : nil)
+  
+  def screen_name=(value)
+    self.login = value
+  end
+  
+  def sync
+    begin
+      user_id = self.id
+      info = User.twitter_client.users.show.json(:id =&gt; user_id)
+      info = info.marshal_dump.stringify_keys
+      self.assign_twitter_attributes(info)
+      self.id = user_id
+      self.login = info['screen_name']
+      self.last_synced_at = Time.now
+    
+      self.save
+    rescue Grackle::TwitterError
+      RAILS_DEFAULT_LOGGER.error &quot;Could not sync #{self.id}&quot;
+    end
+  end
+  
+  def fetch_latest_statuses
+    self.fetch_statuses(1, self.statuses.maximum(:id))
+  end
+  
+  def fetch_statuses(page=1, since_id=1)
+    return unless self.statuses_count.to_i &gt; 0
+    more_tweets = true
+    while more_tweets
+       tweet_count = fetch_statuses_page(page, since_id)
+       more_tweets = (tweet_count == 20)
+       page += 1
+    end
+    
+    
+  end
+  
+  def after_save
+    if self.stats.nil?
+      unless self.login.blank?
+        self.create_stats and self.stats.sync
+      end
+    end
   end
 
-  def email=(value)
-    write_attribute :email, (value ? value.downcase : nil)
+  
+  def self.find_or_create_by_screen_name(screen_name)
+    u = User.find_by_login(screen_name)
+    return u unless u.nil?
+    begin
+      info = User.twitter_client.users.show.json(:screen_name =&gt; screen_name)
+      u = User.find_or_create_by_id(info.id)
+      u.assign_twitter_attributes(info.marshal_dump.stringify_keys)
+      u.login = info.screen_name
+      u.last_synced_at = Time.now
+      u.save
+      u
+    rescue Grackle::TwitterError
+      RAILS_DEFAULT_LOGGER.error &quot;Could not retrieve user #{screen_name}&quot;
+      
+    end
+  end
+  
+  def self.twitter_client
+    @twitter_client ||= Grackle::Client.new(:username =&gt; Floxee.username, :password =&gt; Floxee.password)
   end
 
   protected
     
-
-
+    def fetch_statuses_page(page, since_id)
+      begin
+        tweets = User.twitter_client.statuses.user_timeline.json(:user_id =&gt; self.id, :page =&gt; page, :since_id =&gt; since_id)
+        tweets.each do |tweet|
+          tweet.delete_field('user')
+          status_id = tweet.id
+          status = Status.find_or_create_by_id(status_id)
+          status.user_id = self.id
+          status.attributes = tweet.marshal_dump 
+          status.created_at = tweet.created_at
+          status.save
+        end
+        tweets.size
+      rescue Grackle::TwitterError
+        RAILS_DEFAULT_LOGGER.error &quot;Could not retrieve statuses for  #{self.screen_name}&quot;
+      end
+    end
 end</diff>
      <filename>app/models/user.rb</filename>
    </modified>
    <modified>
      <diff>@@ -248,7 +248,6 @@ body
         :text-decoration none
         :border-bottom-style dotted 
         :border-bottom-width 1px
-        :margin-left .5em
 
   .pagination-info
     :float left
@@ -444,6 +443,7 @@ body
     :-webkit-border-radius .3em
     :-moz-outline-radius .3em
     :color #111
+    :text-shadow #efefef 1px 1px 0px
     :display inline-block
     :font-family Helvetica Neue, Helvetica, Arial, Sans-serif
     :font-size 1.1em</diff>
      <filename>app/stylesheets/screen.sass</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,6 @@
     %script{ :type =&gt; &quot;text/javascript&quot;, :src =&gt; &quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot; }
     = javascript_include_tag 'jquery.timeago.js', 'jquery.flot.js',  'application.js'
     = yield :scripts
-    %link{ :rel =&gt; &quot;shortcut icon&quot;, :href =&gt; &quot;/images/favicon.ico&quot;, :type =&gt; &quot;image/ico&quot;}
     %meta{ :content =&gt; &quot;text/html;charset=UTF-8&quot;, &quot;http-equiv&quot; =&gt; &quot;content-type&quot; }
     %title
       = &quot;#{@page_title}&quot;</diff>
      <filename>app/views/layouts/application.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -6,4 +6,15 @@
   = render :partial =&gt; 'shared/bar_graph', :locals =&gt; {:stats =&gt; @most_new_thirty_days}
 .span-7.last
   = render :partial =&gt; 'shared/ranking', :locals =&gt; {:header =&gt; t('most_followed'), :tweeters =&gt; @most_followed, :stat_field =&gt; 'followers_count'}
-  = render :partial =&gt; 'shared/ranking', :locals =&gt; {:header =&gt; t('most_active'), :tweeters =&gt; @most_active, :stat_field =&gt; 'statuses_count' }
\ No newline at end of file
+  = render :partial =&gt; 'shared/ranking', :locals =&gt; {:header =&gt; t('most_active'), :tweeters =&gt; @most_active, :stat_field =&gt; 'statuses_count' }
+  
+- content_for :scripts do
+  :javascript
+    jQuery(document).ready(function() {
+      $('dd').each(function() {
+        var bar = $(this);
+        var w = bar.css('width').replace('px', '');
+        bar.css('width', '0px');
+        bar.animate({width: w+'px'}, 1000);
+      });
+    });
\ No newline at end of file</diff>
      <filename>app/views/main/stats.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
-- person ||= @person
+- user = @person.user if @person and user.nil?
+- user = @organization.user if @organization and user.nil?
 
 - content_for :scripts do 
   :javascript
@@ -17,7 +18,7 @@
          }
        };
        
-       var data = #{person.stats.totals.reverse.to_json};
+       var data = #{user.daily_stats.map{|total| [total.report_date.to_i*1000, total.followers_count]}.reverse.to_json};
        
 
        $.plot($(&quot;#graph&quot;), [data], options );</diff>
      <filename>app/views/people/_graph_scripts.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -2,15 +2,7 @@
 - avatar_size ||= &quot;48x48&quot;
 .person.vcard{:id =&gt; person.id}
   .more-info
-    %a.button.small.dark{:href =&gt; follow_person_path(person.id)}
-      - begin
-        - if false #@twitter_base and @twitter_base.friendship_exists?(current_user.login, person.screen_name)
-          = 'unfollow'
-        - else
-          = 'follow'
-      - rescue Exception =&gt; ex
-        - flash[:error] = ex.message
-        = 'follow'
+    %a.button.small.dark{:href =&gt; follow_person_path(person.id)} follow
   .more-info.stats
     %a{:href =&gt; person_path(person.id)}
       = image_tag(&quot;/images/chart-icon.png&quot;) </diff>
      <filename>app/views/people/_person.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,6 @@
-- person ||= @person
+- user = @person.user if @person and user.nil?
+- user = @organization.user if @organization and user.nil?
+
 %ul#graph-presets
   %li.selected
     %a.max{:href =&gt; &quot;#&quot;}= t('maximum')
@@ -10,16 +12,16 @@
     %a.1w{:href =&gt; &quot;#&quot;}= t('one_week')
 %h3
   = t('follower_stats_by')
-  = link_to('TwitterCounter', &quot;http://twittercounter.com/#{person.screen_name}&quot;)
+  = link_to('TwitterCounter', &quot;http://twittercounter.com/#{user.screen_name}&quot;)
 #graph
 %dl.span-8
   %dt= t('followers')
-  %dd= person.followers_count
+  %dd= user.stats.followers_current
   %dt= t('overall_twitter_rank')
-  %dd= person.stats.rank
+  %dd= user.stats.rank
   %dt= t('average_growth_per_day')
-  %dd= person.stats.average_growth_2w
+  %dd= user.stats.average_growth_2w
   %dt= t('tomorrows_projection')
-  %dd= person.stats.tomorrow
+  %dd= user.stats.tomorrow
   %dt= t('one_month_projection')
-  %dd= person.stats.next_month
\ No newline at end of file
+  %dd= user.stats.next_month
\ No newline at end of file</diff>
      <filename>app/views/people/_stats.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,21 @@
-- person ||= @person
+- user = @person.user if @person and user.nil?
+- user = @organization.user if @organization and user.nil?
+
 %h3
   = t('twitter_vitals')
   %small
     = t('powered_by')
-    = link_to 'follow cost', &quot;http://followcost.com/#{@person.screen_name}&quot;
+    = link_to 'follow cost', &quot;http://followcost.com/#{user.screen_name}&quot;
 %dl.span-8
   %dt= t('average_tweets_per_day')
-  %dd= number_with_precision(person.stats.average_tweets_per_day.to_f)
+  %dd= number_with_precision(user.stats.average_tweets_per_day.to_f)
   %dt= t('average_tweets_per_day_recently')
-  %dd= number_with_precision(person.stats.average_tweets_per_day_recently.to_f)
+  %dd= number_with_precision(user.stats.average_tweets_per_day_recently.to_f)
   %dt
     = t('at_reply_index')
     %img.tip{ :src =&gt; &quot;/images/question.png&quot;, :title =&gt; &quot;The @ reply index is the percentage of recent tweets that are @ replies&quot;, :alt =&gt; &quot;what is the @ reply index&quot;}
-  %dd= person.stats.at_reply_index
+  %dd= user.stats.at_reply_index
   %dt
     = t('political_index')
     %img.tip{ :src =&gt; &quot;/images/question.png&quot;, :title =&gt; &quot;The political index is the percentage of recent tweets that mention politics&quot;, :alt =&gt; &quot;what is the political index&quot;}
-  %dd= person.stats.political_index
+  %dd= user.stats.political_index</diff>
      <filename>app/views/people/_vitals.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -16,8 +16,8 @@
     %label
       = &quot;#{t('sort_by')}:&quot;
       %select{:name =&gt; 'sort'}
-        %option{:value =&gt; 'last_name'}= t('last_name')
-        %option{:value =&gt; 'followers_count'}= t('followers')
+        %option{:value =&gt; 'people.last_name'}= t('last_name')
+        %option{:value =&gt; 'users.followers_count'}= t('followers')
     %label
       = &quot;#{t('direction')}:&quot;
       %select{:name =&gt; 'reverse'}</diff>
      <filename>app/views/people/index.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 %h3= header
 %ol.ranking
   - tweeters.each do |tweeter|
-    %li= link_to &quot;#{tweeter.display_name} (#{tweeter[stat_field]}) &quot;, person_path(tweeter.id)
\ No newline at end of file
+    - total = tweeter.send(stat_field.to_sym)
+    %li= link_to &quot;#{tweeter.display_name} (#{number_with_delimiter(total)}) &quot;, person_path(tweeter.id)
\ No newline at end of file</diff>
      <filename>app/views/shared/_ranking.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,5 @@
 - unless params[:q].blank?
-  %h3.search-filter
+  %h3.search-filter.clear
     = t('searching_for')
     %em= params[:q]
     = link_to t('clear'), {:q =&gt; nil}, :class =&gt; 'clear-search'
\ No newline at end of file</diff>
      <filename>app/views/shared/_search_filter.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -13,9 +13,9 @@
 %ul.tweetstream
   - tweets[0..(limit-1)].each do |tweet|
     %li{:class =&gt; cycle('', 'alt')}
-      = link_to(image_tag(tweet.person.profile_image_url.gsub(/_normal./, '_bigger.'), :size =&gt; avatar_size), twitter_user_url(tweet.from_user), :class =&gt; 'avatar')
-      = link_to tweet.person.display_name, person_path(tweet.person_id)
-      = &quot;: #{twitter_auto_link highlight(tweet.text, params[:q])}&quot;
+      = link_to(image_tag(tweet.user.profile_image_url.gsub(/_normal./, '_bigger.'), :size =&gt; avatar_size), twitter_user_url(tweet.user.screen_name), :class =&gt; 'avatar')
+      = detail_link_for_tweet(tweet)
+      = &quot;: #{twitter_auto_link tweet.text}&quot;
       %a.timeago{:title =&gt; tweet.created_at.iso8601, :href =&gt; twitter_status_path(tweet)}= tweet.created_at.zone.to_s
 - if show_pagination
   = will_paginate(@tweets, :previous_label =&gt; t('previous'), :next_label =&gt; t('next'))
\ No newline at end of file</diff>
      <filename>app/views/shared/_tweetstream.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -37,7 +37,7 @@ chris:
   updated_at: 2008-12-15 18:46:58
   created_at: 2008-12-15 18:46:58
   email: 
-  screen_name: chrismccroskey
+  screen_name: curvezilla
 
 jason: 
   id: &quot;4&quot;</diff>
      <filename>db/bootstrap/people.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,2 @@
 require 'floxee'
-
-ActionView::Base.send :include, FloxeeHelper 
-ActionController::Base.class_eval do 
-  
-  # gross hack for Memcached
-  before_filter :load_models
-
-  protected
-    def load_models
-      # gross hack for memcached
-      Person
-      TwitterStatus
-      Signature
-      Petition
-      TwitterUserStats
-    end
-  
-end
\ No newline at end of file
+ActionView::Base.send :include, FloxeeHelper 
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,18 @@
 # Floxee
 module Floxee
   class Error &lt; StandardError; end
-
+ 
   def self.config(environment=RAILS_ENV)
     @config ||= {}
     @config[environment] ||= YAML.load(File.open(RAILS_ROOT + '/config/floxee.yml').read)[environment]
   end
-
-  def self.server
-    config['server'] || 'http://127.0.0.1:5984/floxee'    
+ 
+  def self.username
+    config['username']
   end
-
+  
+  def self.password
+    config['password']
+  end
+ 
 end
\ No newline at end of file</diff>
      <filename>lib/floxee.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 namespace :floxee do
   desc &quot;Sync extra files from floxee plugin.&quot;
   task :sync do
+    system &quot;rsync -ruv vendor/plugins/floxee/db/migrate db&quot;
     system &quot;rsync -ruv vendor/plugins/floxee/public .&quot;
   end
   
@@ -10,39 +11,36 @@ namespace :floxee do
     people = File.open(RAILS_ROOT+'/vendor/plugins/floxee/db/bootstrap/people.yml') {|file| YAML::load(file)}
     
     people.keys.each do |k|
-      begin
-        p = Person.get(k)
-      rescue RestClient::ResourceNotFound
-        p = Person.new
-      end
-      if p
-        p.merge! people[k]
-        puts &quot;Importing #{p.display_name}&quot;
-        p.save!
+      info = people[k]
+      puts &quot;Importing #{info['first_name']} #{info['last_name']}&quot;
+      if info['id']
+        person = Person.find_or_create_by_id(info['id'])
+        info.delete('id')
+        person.update_attributes(info)
       else
-        puts &quot;Couldn't find or create user #{people[k]}&quot;
+        person = Person.create(info)
       end
     end
   end
   
   desc &quot;Fetch stats from TwitterCounter and FollowCost&quot;
   task :fetch_stats =&gt; :environment do
-    Person.all.each do |p|
-      p.stats.fetch if p.stats
+    User.all.each do |p|
+      p.user.stats.sync if p.user and p.user.stats
     end
   end
   
   desc &quot;Fetch latest Twitter statuses from search api&quot;
-  task :fetch_tweets =&gt; :environment do
+  task :fetch_latest_tweets =&gt; :environment do
     Person.all.each do |p|
-      p.fetch_latest_statuses
+      p.user.fetch_latest_statuses if p.user
     end
   end
     
   desc &quot;Fetch latest twitter user profile info from Twitter api&quot;
   task :fetch_info =&gt; :environment do
     Person.all.each do |p|
-      p.fetch_info
+      p.user.sync
     end
   end
   </diff>
      <filename>tasks/floxee_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>app/controllers/admin/users_controller.rb</filename>
    </removed>
    <removed>
      <filename>app/models/twitter_status.rb</filename>
    </removed>
    <removed>
      <filename>app/models/twitter_user_stats.rb</filename>
    </removed>
    <removed>
      <filename>app/views/admin/users/index.html.haml</filename>
    </removed>
    <removed>
      <filename>public/images/favicon.ico</filename>
    </removed>
    <removed>
      <filename>public/images/favicon.png</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>3d53826f02b1ba805fc05d4ab480babd108e5841</id>
    </parent>
  </parents>
  <author>
    <name>Jim Mulholland</name>
    <email>jim@jim-mb-pro.local</email>
  </author>
  <url>http://github.com/squeejee/floxee/commit/c0fbe9f36895eacc61bba0089b351018f5c618d1</url>
  <id>c0fbe9f36895eacc61bba0089b351018f5c618d1</id>
  <committed-date>2009-04-09T08:26:07-07:00</committed-date>
  <authored-date>2009-04-09T08:26:07-07:00</authored-date>
  <message>Merge mysql code</message>
  <tree>75598bff6b03a94a695737ee9c48504996ee675c</tree>
  <committer>
    <name>Jim Mulholland</name>
    <email>jim@jim-mb-pro.local</email>
  </committer>
</commit>
