Created
October 16, 2008 20:15
-
-
Save fairchild/17246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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