Sha256: e3f6a56f7ceb9e7cbbdd0342b5ad4fe4b637b5dba5c025e8beb3037d61d18d7c

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

class WelcomeController < ApplicationController
  def index
    flash.keep
    if Task.find_started.size > 0
      redirect_to :controller => 'tasks', :action => :list_started
      return
    end
    if Project.count == 0
      redirect_to :controller => 'projects', :action => :new
      return
    end
    active_periods = Period.find(:all).select {|period| period.active?(true)}
    my_active_periods = active_periods.select {|period| period.party.includes?(current_user)}
    unless my_active_periods.empty?
      my_active_periods = my_active_periods.sort_by {|p| p.required_speed}
      my_active_periods_required_speed = my_active_periods.map {|p| p.required_speed}
      most_urgent_period = my_active_periods.last
    else
      most_urgent_period = active_periods.sort_by {|p| p.required_speed}.last
    end
    if most_urgent_period
      redirect_to :controller => 'periods', :action => :show, :id => most_urgent_period
      return
    end
    most_urgent_project = Project.find(:first, :order => :id)
    redirect_to :controller => 'projects', :action => :show, :id => most_urgent_project.id
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
backlog-0.37.2 app/controllers/welcome_controller.rb
backlog-0.37.1 app/controllers/welcome_controller.rb