class Trackington::SprintRepository
Public Class Methods
new(project_id)
click to toggle source
# File lib/trackington/app/sprints.rb, line 7 def initialize(project_id) @project_id = project_id end
Public Instance Methods
backlog()
click to toggle source
# File lib/trackington/app/sprints.rb, line 51 def backlog query = Models::Sprint.where(project_id: @project_id, is_backlog: true) backlog = query.first Sprint.new(backlog) end
complete_sprint()
click to toggle source
# File lib/trackington/app/sprints.rb, line 32 def complete_sprint return if current.nil? current.tasks.move_to(backlog.id) current.end end
create(data)
click to toggle source
# File lib/trackington/app/sprints.rb, line 11 def create(data) data[:project_id] = @project_id sprint = Models::Sprint.new(data) sprint.is_active = true if current.nil? sprint.save end
current()
click to toggle source
# File lib/trackington/app/sprints.rb, line 18 def current db_sprint = Models::Sprint.where(project_id: @project_id, is_active: true).first return db_sprint if db_sprint.nil? Sprint.new(db_sprint) end
get(sprint_id)
click to toggle source
# File lib/trackington/app/sprints.rb, line 27 def get(sprint_id) db_sprint = Models::Sprint.find(sprint_id) Sprint.new(db_sprint) end
start_sprint()
click to toggle source
# File lib/trackington/app/sprints.rb, line 39 def start_sprint project_sprints = Models::Sprint.where(project_id: @project_id) next_sprint_db = project_sprints.where('start_time > ?', Date.today).first return if next_sprint_db.nil? next_sprint = Sprint.new(next_sprint_db) backlog.tasks.move_to(next_sprint.id) next_sprint.start end