Skip to content

Commit

Permalink
[ML4SE-524] Run saving to the database in the background (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 authored Mar 14, 2024
1 parent c9e66e1 commit b57ccd1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import io.ktor.server.plugins.*
import io.ktor.server.response.*
import io.ktor.server.routing.*
import io.ktor.server.util.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import org.jetbrains.research.tasktracker.util.createLogFile
import org.jetbrains.research.tasktracker.util.logFile.parseLogFile
Expand All @@ -20,10 +22,10 @@ fun Routing.uploadLogFile() {
val logFileType = parameters["logFileType"] ?: DEFAULT_FOLDER
val researchId = parameters.getOrFail<Int>("id")
val logFile = createLogFile(logFileType, researchId)
call.respond(HttpStatusCode.OK)
launch {
CoroutineScope(Job()).launch {
logFile.parseLogFile(logFileType, researchId)
}
call.respond(HttpStatusCode.OK)
} catch (e: MissingRequestParameterException) {
call.respond(HttpStatusCode.BadRequest, e.localizedMessage)
} catch (e: ParameterConversionException) {
Expand Down

0 comments on commit b57ccd1

Please sign in to comment.