Class: Trackington::SprintRepository
- Inherits:
-
Object
- Object
- Trackington::SprintRepository
- Defined in:
- lib/trackington/app/sprints.rb
Instance Method Summary collapse
- #backlog ⇒ Object
- #complete_sprint ⇒ Object
- #create(data) ⇒ Object
- #current ⇒ Object
- #get(sprint_id) ⇒ Object
-
#initialize(project_id) ⇒ SprintRepository
constructor
A new instance of SprintRepository.
- #start_sprint ⇒ Object
Constructor Details
#initialize(project_id) ⇒ SprintRepository
Returns a new instance of SprintRepository.
7 8 9 |
# File 'lib/trackington/app/sprints.rb', line 7 def initialize(project_id) @project_id = project_id end |
Instance Method Details
#backlog ⇒ Object
51 52 53 54 55 |
# 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 ⇒ Object
32 33 34 35 36 37 |
# 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) ⇒ Object
11 12 13 14 15 16 |
# 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 ⇒ Object
18 19 20 21 22 23 24 25 |
# 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) ⇒ Object
27 28 29 30 |
# 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 ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# 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 |