<commit_before>package controllers

import actors.SessionHandler
import controllers.UserManagement._
import models._
import play.api.mvc.{ Action, Controller }
import play.libs.Akka
import utils.Security.Authentication

import scala.concurrent.Future

object FirstTimeSetupController extends Controller with Authentication {

  import akka.pattern.ask
  import akka.util.Timeout
  import scala.concurrent.duration._
  import scala.concurrent.ExecutionContext.Implicits.global

  implicit val timeout = Timeout(5.seconds)
  val sessionsHandler = Akka.system.actorSelection("user/sessions")

  def setupStudent() = hasSession { session ⇒
    Action.async { implicit request ⇒
      for {
        name ← (sessionsHandler ? SessionHandler.NameRequest(session.user)).mapTo[(String, String)]
        degrees ← Degrees.all()
      } yield {
        val filledForm = UserForms.studentForm.fill(Student(session.user, name._1, name._2, "", "", "", ""))
        Ok(views.html.firstTimeInputStudents(degrees, filledForm))
      }
    }
  }

  def setupUser() = hasSession { session ⇒
    Action.async { implicit request ⇒
      for (name ← (sessionsHandler ? SessionHandler.NameRequest(session.user)).mapTo[(String, String)]) yield {
        val filledForm = UserForms.userForm.fill(User(session.user, name._1, name._2, "", ""))
        Ok(views.html.firstTimeInputUser(filledForm))
      }
    }
  }
}<commit_msg>recover with empty form<commit_after>package controllers

import actors.SessionHandler
import controllers.UserManagement._
import models._
import play.api.mvc.{ Action, Controller }
import play.libs.Akka
import utils.Security.Authentication

import scala.concurrent.Future
import scala.util.control.NonFatal

object FirstTimeSetupController extends Controller with Authentication {

  import akka.pattern.ask
  import akka.util.Timeout
  import scala.concurrent.duration._
  import scala.concurrent.ExecutionContext.Implicits.global

  implicit val timeout = Timeout(5.seconds)
  val sessionsHandler = Akka.system.actorSelection("user/sessions")

  def setupStudent() = hasSession { session ⇒
    Action.async { implicit request ⇒
      (for {
        name ← (sessionsHandler ? SessionHandler.NameRequest(session.user)).mapTo[(String, String)]
        degrees ← Degrees.all()
      } yield {
        val filledForm = UserForms.studentForm.fill(Student(session.user, name._1, name._2, "", "", "", ""))
        Ok(views.html.firstTimeInputStudents(degrees, filledForm))
      }).recoverWith {
        case NonFatal(t) =>
          for{
            degrees <- Degrees.all()
          } yield Ok(views.html.firstTimeInputStudents(degrees, UserForms.studentForm))
      }
    }
  }

  def setupUser() = hasSession { session ⇒
    Action.async { implicit request ⇒
      (for (name ← (sessionsHandler ? SessionHandler.NameRequest(session.user)).mapTo[(String, String)]) yield {
        val filledForm = UserForms.userForm.fill(User(session.user, name._1, name._2, "", ""))
        Ok(views.html.firstTimeInputUser(filledForm))
      }).recoverWith {
        case NonFatal(t) =>
          for{
            degrees <- Degrees.all()
          } yield Ok(views.html.firstTimeInputUser(UserForms.userForm))
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.11439229095430525, 'fraction_numerical': 0.003108486167236556, 'mean_word_length': 3.494413407821229, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3392097', 'n_tokens_mistral': 939, 'n_tokens_neox': 931, 'n_words': 196}