mirror of
https://github.com/smyalygames/checklist-tester.git
synced 2025-05-18 14:34:12 +02:00
fix(connector): id not being fetched from database after insert
This commit is contained in:
parent
2efc105ef2
commit
c615149624
@ -4,7 +4,6 @@ import io.anthonyberg.connector.shared.database.ActionResultDatabase
|
|||||||
import io.anthonyberg.connector.shared.database.DriverFactory
|
import io.anthonyberg.connector.shared.database.DriverFactory
|
||||||
import io.anthonyberg.connector.shared.database.TestDatabase
|
import io.anthonyberg.connector.shared.database.TestDatabase
|
||||||
import kotlinx.datetime.Clock
|
import kotlinx.datetime.Clock
|
||||||
import kotlinx.datetime.Instant
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database transactions for testing procedures
|
* Database transactions for testing procedures
|
||||||
@ -35,15 +34,11 @@ class TestTransaction (driverFactory: DriverFactory) {
|
|||||||
* Tells the database that the test has ended
|
* Tells the database that the test has ended
|
||||||
*
|
*
|
||||||
* @param id ID of the Test
|
* @param id ID of the Test
|
||||||
*
|
|
||||||
* @return The final time for when the test ended
|
|
||||||
*/
|
*/
|
||||||
fun endTest(id: Int): Instant {
|
fun endTest(id: Int) {
|
||||||
val currentTime = Clock.System.now()
|
val currentTime = Clock.System.now()
|
||||||
|
|
||||||
testDb.endTest(testId = id.toLong(), endUTC = currentTime.toString())
|
testDb.endTest(testId = id.toLong(), endUTC = currentTime.toString())
|
||||||
|
|
||||||
return currentTime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,10 +67,8 @@ class TestTransaction (driverFactory: DriverFactory) {
|
|||||||
* Tells the database that the test has ended and adds the final state
|
* Tells the database that the test has ended and adds the final state
|
||||||
*
|
*
|
||||||
* @param id ID of the ActionResult
|
* @param id ID of the ActionResult
|
||||||
*
|
|
||||||
* @return The time for when the test for the specific action finished
|
|
||||||
*/
|
*/
|
||||||
fun finishAction(id: Int, endState: String): Instant {
|
fun finishAction(id: Int, endState: String) {
|
||||||
val currentTime = Clock.System.now()
|
val currentTime = Clock.System.now()
|
||||||
|
|
||||||
actionResultDb.finishResult(
|
actionResultDb.finishResult(
|
||||||
@ -83,7 +76,5 @@ class TestTransaction (driverFactory: DriverFactory) {
|
|||||||
endState = endState,
|
endState = endState,
|
||||||
endUTC = currentTime.toString()
|
endUTC = currentTime.toString()
|
||||||
)
|
)
|
||||||
|
|
||||||
return currentTime
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,14 +15,18 @@ internal class ActionResultDatabase (driverFactory: DriverFactory) {
|
|||||||
initState: String,
|
initState: String,
|
||||||
startUTC: String
|
startUTC: String
|
||||||
): Long {
|
): Long {
|
||||||
dbQuery.startResult(
|
val id = dbQuery.transactionWithResult {
|
||||||
testId = testId,
|
dbQuery.startResult(
|
||||||
actionId = actionId,
|
testId = testId,
|
||||||
initState = initState,
|
actionId = actionId,
|
||||||
startUTC = startUTC
|
initState = initState,
|
||||||
)
|
startUTC = startUTC
|
||||||
|
)
|
||||||
|
|
||||||
return dbQuery.lastInsertedRowId().executeAsOne()
|
dbQuery.lastInsertedRowId().executeAsOne()
|
||||||
|
}
|
||||||
|
|
||||||
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,12 +10,15 @@ internal class TestDatabase (driverFactory: DriverFactory) {
|
|||||||
* @return ID of the Test created
|
* @return ID of the Test created
|
||||||
*/
|
*/
|
||||||
internal fun startTest(procedureId: Long, startUTC: String) : Long {
|
internal fun startTest(procedureId: Long, startUTC: String) : Long {
|
||||||
dbQuery.startTest(
|
val id = dbQuery.transactionWithResult {
|
||||||
procedureId = procedureId,
|
dbQuery.startTest(
|
||||||
startUTC = startUTC,
|
procedureId = procedureId,
|
||||||
)
|
startUTC = startUTC,
|
||||||
|
)
|
||||||
|
dbQuery.lastInsertedRowId().executeAsOne()
|
||||||
|
}
|
||||||
|
|
||||||
return dbQuery.lastInsertedRowId().executeAsOne()
|
return id
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user