This commit is contained in:
parent
1ac8eaa49c
commit
c6d2b85876
@ -5,12 +5,4 @@ import api.ApiObject
|
||||
|
||||
interface IResultObjectService{
|
||||
fun addOne(apiObject: ApiObject)
|
||||
suspend fun getAllResultObjects(): List<ApiObject>
|
||||
suspend fun getResultObjectbyTag(tag: String): ApiObject?
|
||||
suspend fun getResultObjectbyDate(date: LocalDate): List<ApiObject>?
|
||||
suspend fun getResultObjectbeforeDate(date: LocalDate): List<ApiObject>?
|
||||
suspend fun getResultObjectafterDate(date: LocalDate): List<ApiObject>?
|
||||
suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject>?
|
||||
suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject>?
|
||||
suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject>?
|
||||
}
|
@ -20,57 +20,4 @@ class ResultObjectService : IResultObjectService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getAllResultObjects(): List<ApiObject> = dbQuery {
|
||||
ResultObjects.selectAll().map { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjectbyTag(tag: String): ApiObject? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.tag eq tag)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
.singleOrNull()
|
||||
}
|
||||
|
||||
override suspend fun getResultObjectbyDate(date: LocalDate): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.date eq date)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjectbeforeDate(date: LocalDate): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.date less date)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjectafterDate(date: LocalDate): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.date greater date)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.probability greater probability)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.probability less probability)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
override suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject>? = dbQuery {
|
||||
ResultObjects.select {
|
||||
(ResultObjects.probability eq probability)
|
||||
}.mapNotNull { toResultObject(it) }
|
||||
}
|
||||
|
||||
private fun toResultObject(row: ResultRow): ApiObject =
|
||||
ApiObject(
|
||||
tag = row[ResultObjects.tag],
|
||||
probability = row[ResultObjects.probability]
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user