Skip to content

Commit

Permalink
[ML4SE-267] research Unique Id.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikrise2 committed Dec 20, 2023
1 parent b6db66d commit 82f58f0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import org.jetbrains.research.tasktracker.config.YamlConfigLoadStrategy
import java.io.File

@Serializable
class PluginInfoConfig(val pluginName: String, val pluginDescription: String) : BaseConfig {
class PluginInfoConfig(val pluginName: String, val pluginDescription: String, val researchId: String) : BaseConfig {
override val configName: String
get() = CONFIG_FILE_PREFIX

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ object IdRequests {
?: error("MainPageConfig must not be null")
try {
requireNotNull(GlobalPluginStorage.userId) { "User id is not defined" }
val researchId = TaskTrackerPlugin.mainConfig.pluginInfoConfig?.let {
it.researchId
} ?: error("Plugin info config is uninitialized")
return@runBlocking client.submitForm(
url = url,
formParameters = mapOf(
"name" to pluginInfoConfig.pluginName,
"description" to pluginInfoConfig.pluginDescription,
"user_id" to GlobalPluginStorage.userId.toString()
"user_id" to GlobalPluginStorage.userId.toString(),
"research_unique_id" to researchId
).buildParameters()
).body<Int>()
} catch (e: IllegalArgumentException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ fun Panel.agreementAcceptance() {
setNextAction {
checkAgreementInputs().runOnSuccess {
if (!it) {
GlobalPluginStorage.agreementChecker?.let { agreement ->
GlobalPluginStorage.userId = IdRequests.getUserId(agreement.name, agreement.email).alsoIfNull {
notifyError(
project,
"Connection problems with the server, check tour connection or try later"
)
}
}
GlobalPluginStorage.currentResearchId = IdRequests.getResearchId()
welcomePage()
} else {
notifyError(project, UIBundle.message("ui.please.fill"))
Expand All @@ -44,16 +53,6 @@ fun Panel.agreementAcceptance() {
fun Panel.welcomePage() {
loadBasePage(MainPageTemplate.loadCurrentTemplate(), "ui.button.next", false)
setNextAction {
GlobalPluginStorage.agreementChecker?.let {
GlobalPluginStorage.userId = IdRequests.getUserId(it.name, it.email).alsoIfNull {
notifyError(
project,
"Connection problems with the server, either you entered an incorrect email or name."
)
return@setNextAction
}
}
GlobalPluginStorage.currentResearchId = IdRequests.getResearchId()
TaskTrackerPlugin.initializationHandler.setupEnvironment(project)
startTracking()
processScenario()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pluginName: Refactoring course
pluginDescription: "We want to track your progress through the code refactoring course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
pluginDescription: "We want to track your progress through the code refactoring course in order to collect data on file changes during the course completion. Please, when you are ready, press the next button."
researchId: "RefactoringCourse"
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Research(id: EntityID<Int>) : Entity<Int>(id) {
var name by Researches.name
var description by Researches.description
var user by User referencedOn Researches.user
var researchUniqueId by Researches.researchUniqueId
}

/**
Expand All @@ -31,4 +32,9 @@ object Researches : IntIdTable() {
* User who took part in the research.
*/
val user = reference("user", Users)

/**
* Unique id for research
*/
val researchUniqueId = text("research_unique_id")
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fun Routing.createResearch() {
name = formParameters.getOrFail("name")
description = formParameters["description"]
user = User[formParameters.getOrFail<Int>("user_id")]
researchUniqueId = formParameters.getOrFail("research_unique_id")
}.id.value
}
call.respondText(
Expand Down

0 comments on commit 82f58f0

Please sign in to comment.