Skip to content

Instantly share code, notes, and snippets.

@fairchild
Created October 16, 2008 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fairchild/17246 to your computer and use it in GitHub Desktop.
Save fairchild/17246 to your computer and use it in GitHub Desktop.
class Project < Sequel::Model
one_to_many :milestones
one_to_many :tickets
def self.update_from_lighthouse(project_id=nil, updated_at=nil)
#TODO: allow scoping this call to only records updated_at>?
Lighthouse::Project.find(:all).each do |lh_project|
if project=Project[lh_project.id]
project.update_from_lighthouse
else
Project.create(:name=>lh_project.name, :description=>lh_project.description, :open_tickets_count=>lh_project.open_tickets_count)
end
end
end
def update_from_lighthouse
@project = Lighthouse::Project.find( id )
self.update(:name=>@project.name, :description=>@project.description, :open_tickets_count=>@project.open_tickets_count)
end
def gather_tickets
@project.tickets.each do |ticket|
Ticket.update_or_create_from_lighthouse(ticket.id)
end
end
def to_s
name || id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment