<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -29,9 +29,11 @@ class FlickrPhoto &lt; ActiveRecord::Base
   end
   
   # Updates existing images with tags/assocs etc.
-  def self.update_existing(event)
+  # Optionally specify a time - this will limit us to updating images
+  # added  later than that. Defaults to the beginning of time.
+  def self.update_existing(event, since = DateTime.new(1))
     license_hash = license_text_hash
-    flickr_ids_in_db(event).each {|id| create_or_update_image(event, id, license_hash)}
+    flickr_ids_in_db(event, since).each {|id| create_or_update_image(event, id, license_hash)}
   end
   
   # returns a hash, keyed by the flickr licence id, containing the text
@@ -47,6 +49,7 @@ class FlickrPhoto &lt; ActiveRecord::Base
   
   # Creates or updates and image in an event for the given flickr ID.
   def self.create_or_update_image(event, flickrid, license_hash=nil)
+    
     logger.info &quot;Updating image #{flickrid} in event #{event.name}&quot;
     # load the image, or create a new one
     fp = FlickrPhoto.find_by_flickrid(flickrid)
@@ -137,9 +140,11 @@ class FlickrPhoto &lt; ActiveRecord::Base
     fp.save    
   end
 
-  def self.flickr_ids_in_db(event)
+  def self.flickr_ids_in_db(event,since=DateTime.new(1))
     ids = Array.new
-    event.flickr_photos.each {|fp| ids &lt;&lt; fp.flickrid}
+    event.flickr_photos.find(:all, 
+      :conditions =&gt; [&quot;created_at &gt; ?&quot;, since]).
+      each {|fp| ids &lt;&lt; fp.flickrid}
     ids
   end
   </diff>
      <filename>app/models/flickr_photo.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,9 @@ namespace :fetcher do
   desc 'Runs all normal fetch tasks'
   task :all_new =&gt; [:flickr_new, :viddler_new, :twitter]
   desc 'Runs all normal update tasks'
-  task :all_update =&gt; [:flickr_update, :viddler_update]
+  task :all_update =&gt; [:flickr_update_all, :viddler_update]
+  desc 'Runs recent normal update tasks'
+  task :recent_update =&gt; [:flickr_update_recent, :viddler_update]
 
   
   desc 'Fetches new images from flickr for all events'
@@ -16,12 +18,22 @@ namespace :fetcher do
     Event.find(:all).each {|event| FlickrPhoto.fetch_new(event)}
   end
   
-  desc 'Updates existing flickr photos.'
-   task :flickr_update do
+  desc 'Update all photos in our system changed in the last month'
+   task :flickr_update_recent do
      puts &quot;Starting Flickr update of images in db&quot;
-     Event.find(:all).each {|event| FlickrPhoto.update_existing(event)}
+     Event.find(:all).each do |event| 
+       FlickrPhoto.update_existing(event, 1.month.ago)
+     end
    end
    
+   desc 'Update all photos in our system'
+    task :flickr_update_all do
+      puts &quot;Starting Flickr update of images in db&quot;
+      Event.find(:all).each do |event| 
+        FlickrPhoto.update_existing(event)
+      end
+    end
+   
   desc 'Fetches new videos from viddler for all events'
   task :viddler_new do
    puts &quot;Starting Viddler Fetch of new videos&quot;</diff>
      <filename>lib/tasks/fetcher.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>801f90ceecf73ea03545942c7c6e4e4729e73fca</id>
    </parent>
  </parents>
  <author>
    <name>Lincoln Stoll</name>
    <email>lstoll@lstoll.net</email>
  </author>
  <url>http://github.com/webjam/webjam/commit/55f31cf648ae5758f3c854f9fffea7a31471336e</url>
  <id>55f31cf648ae5758f3c854f9fffea7a31471336e</id>
  <committed-date>2009-10-07T12:35:52-07:00</committed-date>
  <authored-date>2009-10-07T12:35:52-07:00</authored-date>
  <message>Adding an update_recent fetch task, that only includes images changed in the last month - so can be run more often to ensure we are up to date for events, without killing system. Closes #11</message>
  <tree>a1472da5a6a33b5c8d5238f5c91050dddf7e04ad</tree>
  <committer>
    <name>Lincoln Stoll</name>
    <email>lstoll@lstoll.net</email>
  </committer>
</commit>
