<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>log/.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -7,6 +7,7 @@ then you win. &#8211;- Mahatma Gandhi
 Mon, May 11, 2009
 ---------------------------------------------------------------------
 - Implemented live search for leads that can be reused in other controllers.
+- Fixed demo data generation to produce random recently viewed items list.
 
 Sun, May 10, 2009
 ---------------------------------------------------------------------</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -30,27 +30,30 @@ namespace :crm do
       Rake::Task[&quot;crm:settings:load&quot;].invoke
 
       # Simulate random user activities.
-      %w(Account Campaign Contact Lead Opportunity Task).each do |model|
-        puts &quot;Loading user activities for #{model.downcase.pluralize}...&quot;
-        assets = model.constantize.send(:find, :all)
-        assets.each do |subject|
-          info = subject.respond_to?(:full_name) ? subject.full_name : subject.name
-          Activity.create(:action =&gt; &quot;created&quot;, :created_at =&gt; subject.created_at, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
-          Activity.create(:action =&gt; &quot;updated&quot;, :created_at =&gt; subject.updated_at, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
-          if model != &quot;Task&quot;
-            Activity.create(:action =&gt; &quot;viewed&quot;, :created_at =&gt; subject.updated_at + rand(12 * 60).minutes, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
-            comments = Comment.find(:all, :conditions =&gt; [ &quot;commentable_id=? AND commentable_type=?&quot;, subject.id, model ])
-            comments.each_with_index do |comment, i|
-              time = subject.created_at + rand(12 * 60 * i).minutes
-              if time &gt; Time.now
-                time = subject.created_at + rand(600).minutes
-              end
-              comment.update_attribute(:created_at, time)
-              Activity.create(:action =&gt; &quot;commented&quot;, :created_at =&gt; time, :user =&gt; comment.user, :subject =&gt; subject, :info =&gt; info)
+      $stdout.sync = true
+      puts &quot;Generating user activities...&quot;
+      %w(Account Campaign Contact Lead Opportunity Task).inject([]) do |assets, model|
+        assets &lt;&lt; model.constantize.send(:find, :all)
+      end.flatten.shuffle.each do |subject|
+        info = subject.respond_to?(:full_name) ? subject.full_name : subject.name
+        Activity.create(:action =&gt; &quot;created&quot;, :created_at =&gt; subject.updated_at, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
+        Activity.create(:action =&gt; &quot;updated&quot;, :created_at =&gt; subject.updated_at, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
+        unless subject.is_a?(Task)
+          time = subject.updated_at + rand(12 * 60).minutes
+          Activity.create(:action =&gt; &quot;viewed&quot;, :created_at =&gt; time, :user =&gt; subject.user, :subject =&gt; subject, :info =&gt; info)
+          comments = Comment.find(:all, :conditions =&gt; [ &quot;commentable_id=? AND commentable_type=?&quot;, subject.id, subject.class.name ])
+          comments.each_with_index do |comment, i|
+            time = subject.created_at + rand(12 * 60 * i).minutes
+            if time &gt; Time.now
+              time = subject.created_at + rand(600).minutes
             end
+            comment.update_attribute(:created_at, time)
+            Activity.create(:action =&gt; &quot;commented&quot;, :created_at =&gt; time, :user =&gt; comment.user, :subject =&gt; subject, :info =&gt; info)
           end
         end
+        print &quot;.&quot; if subject.id % 10 == 0
       end
+      puts
     end
 
     desc &quot;Reset the database and reload demo data along with default application settings&quot;</diff>
      <filename>lib/tasks/fat_free_crm.rake</filename>
    </modified>
    <modified>
      <diff>@@ -43,6 +43,6 @@ account&lt;%= i %&gt;:
   shipping_address : |
                      &lt;%= addr1 %&gt;
                      &lt;%= addr2 %&gt;
-  created_at       : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at       : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at       : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/accounts.yml</filename>
    </modified>
    <modified>
      <diff>@@ -138,6 +138,6 @@ campaign&lt;%= i %&gt;:
   starts_on           : &lt;%= starts %&gt;
   ends_on             : &lt;%= starts + rand(50).days %&gt;
   objectives          : &lt;%= Faker::Lorem.sentence %&gt;
-  created_at          : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at          : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at          : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/campaigns.yml</filename>
    </modified>
    <modified>
      <diff>@@ -66,6 +66,6 @@ contact_&lt;%= i %&gt;:
                 &lt;%= Faker::Address.city + &quot;, &quot; + Faker::Address.us_state_abbr + &quot; &quot; + Faker::Address.zip_code %&gt;
   born_on     : &lt;%= Date.today - (rand(20) + 20).years - rand(200).days %&gt;
   do_not_call : false
-  created_at  : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at  : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at  : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/contacts.yml</filename>
    </modified>
    <modified>
      <diff>@@ -69,6 +69,6 @@ lead&lt;%= i %&gt;:
                 &lt;%= Faker::Address.street_address + &quot; &quot; + Faker::Address.secondary_address %&gt;
                 &lt;%= Faker::Address.city + &quot;, &quot; + Faker::Address.us_state_abbr + &quot; &quot; + Faker::Address.zip_code %&gt;
   do_not_call : false
-  created_at  : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at  : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at  : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/leads.yml</filename>
    </modified>
    <modified>
      <diff>@@ -42,6 +42,6 @@ opportunity_&lt;%= i %&gt;:
   probability : &lt;%= %w(won lost).include?(the_stage) ? 100 : (rand(8) + 1) * 10 %&gt;
   amount      : &lt;%= (rand(8) + 1) * 100_000 %&gt;
   closes_on   : &lt;%= Date.today + (rand(100) + 10).days %&gt;
-  created_at  : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at  : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at  : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/opportunities.yml</filename>
    </modified>
    <modified>
      <diff>@@ -54,6 +54,6 @@ task&lt;%= i %&gt;:
   bucket       : &lt;%= bucket %&gt;
   due_at       : &lt;%= due_at %&gt;
   completed_at : &lt;%= rand(4) == 0 ? Date.today - rand(5).days : &quot;&quot; %&gt;
-  created_at   : &lt;%= created_at = (rand(60) + 1).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
+  created_at   : &lt;%= created_at = (rand(60) + 2).days.ago + rand(600).minutes; created_at.to_s(:db) %&gt;
   updated_at   : &lt;%= (created_at + rand(36_000).seconds).to_s(:db) %&gt;
 &lt;% end %&gt;</diff>
      <filename>spec/fixtures/tasks.yml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>191ecf8c942e67151a19886a153b1645d0739b5e</id>
    </parent>
  </parents>
  <author>
    <name>Mike Dvorkin</name>
    <email>mike@dvorkin.net</email>
  </author>
  <url>http://github.com/mocra/fat_free_crm/commit/96653c83b17af2911149f7cc891ed282667afa12</url>
  <id>96653c83b17af2911149f7cc891ed282667afa12</id>
  <committed-date>2009-05-11T22:17:26-07:00</committed-date>
  <authored-date>2009-05-11T22:17:26-07:00</authored-date>
  <message>Fixed demo data generation to produce random recently viewed items list</message>
  <tree>99819a18900b0a999fcc7e95d12c25da2a6ead3f</tree>
  <committer>
    <name>Mike Dvorkin</name>
    <email>mike@dvorkin.net</email>
  </committer>
</commit>
