jamesrwhite/minicron

View on GitHub
server/lib/minicron/hub/controllers/index.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Minicron::Hub::App
  get '/' do
    # Get the most recent job execution
    recent = Minicron::Hub::Model::Execution
             .belonging_to(current_user)
             .includes(:job)
             .order(created_at: :desc, started_at: :desc)
             .first

    # Redirect the user to that execution if we found one
    if recent
      redirect "#{route_prefix}/execution/#{recent.id}"
    else
      erb :index, layout: :'layouts/app'
    end
  end
end