Compare commits

...

22 Commits

Author SHA1 Message Date
f7757d31fb upload to docker hub
All checks were successful
continuous-integration/drone/push Build is passing
2022-01-31 23:16:41 +01:00
d638b98d1a Merge branch 'master' of ssh://git.kmlabz.com:2222/birbnetes/output-service-rdb
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-18 16:44:39 +02:00
4fc8db6fa4 use kotlin serialize 2021-08-18 16:44:29 +02:00
1997df3da9 remove deprecated stuff
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-17 18:00:11 +02:00
f46386d465 get count from db layer as well
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-17 16:09:10 +02:00
4f67c48f7a pagination in db layer
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-17 15:57:58 +02:00
5f2d88d3d2 pajeet nation
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-17 15:34:49 +02:00
9c432ae60d update koin
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-16 14:29:49 +02:00
ac4e01b1e9 update gradle
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-12 12:25:23 +02:00
3c3beff2e4 remove consumer and update deps
All checks were successful
continuous-integration/drone/push Build is passing
2021-08-12 12:24:03 +02:00
9793ccc593 update dependencies
All checks were successful
continuous-integration/drone/push Build is passing
2020-11-19 02:38:15 +01:00
204dfcabbc Update 'k8s/deployment.yml'
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-06 14:57:26 +02:00
f27eec0f8f update manifests
All checks were successful
continuous-integration/drone/push Build is passing
2020-08-02 15:29:22 +00:00
264545215b analysis via sonar
All checks were successful
continuous-integration/drone/push Build is passing
2020-07-07 22:58:09 +02:00
2b89400168 use string instead of uuid
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-29 13:27:53 +02:00
8d7f05d122 add back notification
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-29 13:25:22 +02:00
0615d63610 Merge pull request 'Merge improvements' (#1) from kotlin-hazi into master
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-29 13:23:31 +02:00
597c0a24db charset utf8
Some checks reported errors
continuous-integration/drone/push Build was killed
continuous-integration/drone/pr Build is passing
2020-05-22 04:45:32 +02:00
9074619914 queue name
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-22 04:34:16 +02:00
495ebae5f9 use a consumer to interact with db
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-22 04:29:58 +02:00
0e5f4e593f remove cache
All checks were successful
continuous-integration/drone/push Build is passing
2020-05-22 03:41:40 +02:00
609a90adc2 use uuid
Some checks failed
continuous-integration/drone/push Build is failing
2020-05-22 03:40:09 +02:00
14 changed files with 114 additions and 141 deletions

View File

@ -3,42 +3,19 @@ type: docker
name: default name: default
steps: steps:
- name: restore-cache-with-filesystem - name: code-analysis
image: meltwater/drone-cache image: aosapps/drone-sonar-plugin
settings: settings:
backend: "filesystem" sonar_host:
restore: true from_secret: SONAR_HOST
cache_key: "{{ .Repo.Name }}" sonar_token:
archive_format: "gzip" from_secret: SONAR_CODE
filesystem_cache_root: "/tmp/cache"
mount:
- 'build'
- '.gradle'
volumes:
- name: cache
path: /tmp/cache
- name: build_application - name: build_application
image: openjdk:11-jdk image: openjdk:11-jdk
commands: commands:
- ./gradlew build -x test - ./gradlew build -x test
- name: rebuild-cache-with-filesystem
image: meltwater/drone-cache:dev
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: "{{ .Repo.Name }}"
archive_format: "gzip"
filesystem_cache_root: "/tmp/cache"
mount:
- 'build'
- '.gradle'
volumes:
- name: cache
path: /tmp/cache
- name: kaniko - name: kaniko
image: banzaicloud/drone-kaniko image: banzaicloud/drone-kaniko
settings: settings:
@ -52,6 +29,18 @@ steps:
- latest - latest
- ${DRONE_BUILD_NUMBER} - ${DRONE_BUILD_NUMBER}
- name: dockerhub
image: plugins/docker
settings:
repo: birbnetes/${DRONE_REPO_NAME}
username:
from_secret: DOCKERHUB_USER
password:
from_secret: DOCKERHUB_PASSWORD
tags:
- latest
- ${DRONE_BUILD_NUMBER}
- name: ms-teams - name: ms-teams
image: kuperiu/drone-teams image: kuperiu/drone-teams
settings: settings:
@ -59,8 +48,3 @@ steps:
from_secret: TEAMS_WEBHOOK from_secret: TEAMS_WEBHOOK
when: when:
status: [ failure ] status: [ failure ]
volumes:
- name: cache
host:
path: "/tmp/cache"

View File

@ -11,4 +11,4 @@ USER $APPLICATION_USER
COPY ./build/libs/output-service-rdb.jar /app/output-service-rdb.jar COPY ./build/libs/output-service-rdb.jar /app/output-service-rdb.jar
WORKDIR /app WORKDIR /app
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "output-service-rdb.jar"] CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "output-service-rdb.jar"]

View File

@ -7,19 +7,23 @@ buildscript {
dependencies { dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.github.jengelman.gradle.plugins:shadow:5.2.0" classpath "com.github.jengelman.gradle.plugins:shadow:5.2.0"
classpath "org.koin:koin-gradle-plugin:$koin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
} }
} }
plugins {
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.21'
}
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11
} }
apply plugin: 'kotlin' apply plugin: 'kotlin'
apply plugin: 'kotlinx-serialization'
apply plugin: "com.github.johnrengelman.shadow" apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'application' apply plugin: 'application'
apply plugin: 'koin'
group 'com.kmalbz' group 'com.kmalbz'
version '0.0.1' version '0.0.1'
@ -39,26 +43,26 @@ repositories {
} }
dependencies { dependencies {
compile 'org.postgresql:postgresql:42.2.2' compile 'org.postgresql:postgresql:42.2.23'
compile 'org.jetbrains.exposed:exposed-core:0.23.1' compile 'org.jetbrains.exposed:exposed-core:0.33.1'
compile 'org.jetbrains.exposed:exposed-dao:0.23.1' compile 'org.jetbrains.exposed:exposed-dao:0.33.1'
compile 'org.jetbrains.exposed:exposed-jdbc:0.23.1' compile 'org.jetbrains.exposed:exposed-jdbc:0.33.1'
compile 'org.jetbrains.exposed:exposed-java-time:0.23.1' compile 'org.jetbrains.exposed:exposed-java-time:0.33.1'
compile 'com.rabbitmq:amqp-client:2.7.1' compile 'com.zaxxer:HikariCP:5.0.0'
compile 'com.zaxxer:HikariCP:2.7.8' implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2"
compile 'com.viartemev:the-white-rabbit:0.0.5' implementation "org.jetbrains.kotlinx:kotlinx-datetime:0.2.1"
implementation "org.koin:koin-ktor:$koin_version" implementation "io.insert-koin:koin-core:$koin_version"
implementation "io.insert-koin:koin-ktor:$koin_version"
implementation "io.ktor:ktor-serialization:$ktor_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "io.ktor:ktor-server-netty:$ktor_version" implementation "io.ktor:ktor-server-netty:$ktor_version"
implementation "ch.qos.logback:logback-classic:$logback_version" implementation "ch.qos.logback:logback-classic:$logback_version"
implementation "io.ktor:ktor-server-core:$ktor_version" implementation "io.ktor:ktor-server-core:$ktor_version"
implementation "io.ktor:ktor-gson:$ktor_version"
implementation "io.ktor:ktor-server-host-common:$ktor_version" implementation "io.ktor:ktor-server-host-common:$ktor_version"
implementation "io.ktor:ktor-client-core:$ktor_version" implementation "io.ktor:ktor-client-core:$ktor_version"
implementation "io.ktor:ktor-client-core-jvm:$ktor_version" implementation "io.ktor:ktor-client-core-jvm:$ktor_version"
implementation "io.ktor:ktor-client-apache:$ktor_version" implementation "io.ktor:ktor-client-apache:$ktor_version"
implementation "io.ktor:ktor-auth:$ktor_version" implementation "io.ktor:ktor-auth:$ktor_version"
testImplementation "io.ktor:ktor-server-tests:$ktor_version"
} }
kotlin.experimental.coroutines = 'enable' kotlin.experimental.coroutines = 'enable'

View File

@ -1,5 +1,5 @@
ktor_version=1.3.2 ktor_version=1.6.2
kotlin.code.style=official kotlin.code.style=official
kotlin_version=1.3.72 kotlin_version=1.5.21
logback_version=1.2.1 logback_version=1.2.5
koin_version=2.1.5 koin_version=3.1.2

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip

View File

@ -12,4 +12,4 @@ data:
DB_PASSWORD: output-service-supersecret DB_PASSWORD: output-service-supersecret
MQ_HOST: birb-rabbitmq MQ_HOST: birb-rabbitmq
MQ_USERNAME: user MQ_USERNAME: user
MQ_PASSWORD: 1wZVQnP5vy MQ_PASSWORD: F3ACadDRsT

View File

@ -18,7 +18,8 @@ spec:
app: output-service-rdb app: output-service-rdb
spec: spec:
containers: containers:
- image: registry.kmlabz.com/tormakris/output-service-rdb - image: registry.kmlabz.com/birbnetes/output-service-rdb
imagePullPolicy: Always
name: output-service-rdb name: output-service-rdb
envFrom: envFrom:
- configMapRef: - configMapRef:

View File

@ -1,26 +1,16 @@
package com.kmalbz package com.kmalbz
import com.google.gson.Gson
import com.kmalbz.api.model.ApiObject
import com.kmalbz.api.route.OutputServiceRDBServer import com.kmalbz.api.route.OutputServiceRDBServer
import io.ktor.application.* import io.ktor.application.*
import io.ktor.response.* import io.ktor.response.*
import io.ktor.routing.* import io.ktor.routing.*
import io.ktor.http.* import io.ktor.http.*
import io.ktor.gson.*
import io.ktor.features.* import io.ktor.features.*
import org.apache.http.HttpException import org.apache.http.HttpException
import com.kmalbz.database.DatabaseFactory import com.kmalbz.database.DatabaseFactory
import com.kmalbz.database.dao.ResultObjects import com.kmalbz.database.dao.ResultObjects
import com.kmalbz.database.service.ResultObjectService import io.ktor.serialization.*
import io.ktor.util.KtorExperimentalAPI import io.ktor.util.KtorExperimentalAPI
import com.rabbitmq.client.*
import com.typesafe.config.ConfigFactory
import io.ktor.config.HoconApplicationConfig
import com.viartemev.thewhiterabbit.channel.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.jetbrains.exposed.sql.SchemaUtils import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import org.koin.ktor.ext.Koin import org.koin.ktor.ext.Koin
@ -31,8 +21,7 @@ fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@Suppress("unused") // Referenced in application.conf @Suppress("unused") // Referenced in application.conf
fun Application.module() { fun Application.module() {
install(ContentNegotiation) { install(ContentNegotiation) {
gson { json()
}
} }
install(Koin) { install(Koin) {
@ -45,36 +34,6 @@ fun Application.module() {
SchemaUtils.create(ResultObjects) SchemaUtils.create(ResultObjects)
} }
val appConfig = HoconApplicationConfig(ConfigFactory.load())
val factory = ConnectionFactory()
factory.host = appConfig.property("ktor.mq.host").getString()
factory.username = appConfig.property("ktor.mq.username").getString()
factory.password = appConfig.property("ktor.mq.password").getString()
val connection = factory.newConnection()
val channel = connection.createChannel()
val rabbitExchangeName = appConfig.property("ktor.mq.exchange").getString()
channel.exchangeDeclare(rabbitExchangeName, BuiltinExchangeType.FANOUT)
val queueName = channel.queueDeclare().queue
channel.queueBind(queueName, rabbitExchangeName, "")
GlobalScope.launch(Dispatchers.Default) {
connection.channel {
consume(queueName) {
consumeMessageWithConfirm({
val resultObjectService = ResultObjectService()
val rawJson = String(it.body)
val gson = Gson()
val apiObject = gson.fromJson(rawJson,ApiObject::class.java)
resultObjectService.addOne(apiObject)
})
}
}
}
routing { routing {
install(StatusPages) { install(StatusPages) {
exception<HttpException> { exception<HttpException> {

View File

@ -1,8 +1,9 @@
package com.kmalbz.api.model package com.kmalbz.api.model
import com.google.gson.annotations.SerializedName import kotlinx.serialization.Serializable
@Serializable
data class ApiObject( data class ApiObject(
@SerializedName("tag") val tag: String, val tag: String,
@SerializedName("probability") val probability: Double val probability: Double
) )

View File

@ -6,9 +6,9 @@ import io.ktor.http.HttpStatusCode
import io.ktor.response.respond import io.ktor.response.respond
import io.ktor.routing.Routing import io.ktor.routing.Routing
import io.ktor.routing.get import io.ktor.routing.get
import kotlinx.datetime.LocalDateTime
import org.koin.ktor.ext.inject import org.koin.ktor.ext.inject
import java.time.LocalDate
import java.time.format.DateTimeFormatter
/** /**
* Output Service - RDB * Output Service - RDB
@ -19,44 +19,58 @@ class OutputServiceRDBServer {
/** /**
* output * output
*/ */
fun Routing.registerOutput() { fun Routing.registerOutput() {
val resultObjectService by inject<IResultObjectService>() val resultObjectService: IResultObjectService by inject()
get("/output") { get("/output") {
call.respond(resultObjectService.getAllResultObjects()) call.respond(resultObjectService.getAllResultObjects())
} }
get("/output/count") {
call.respond(resultObjectService.getCount())
}
get("/output/page/{page}") {
val page = call.parameters["page"] ?: error(HttpStatusCode.NotAcceptable)
val pageNum = page.toLong()
call.respond(resultObjectService.getPage(pageNum))
}
get("/output/filter/negative") { get("/output/filter/negative") {
val resultList = resultObjectService.getResultObjecLessthanProbability(0.5) ?: call.respond(HttpStatusCode.NotFound) val resultList =
resultObjectService.getResultObjecLessthanProbability(0.5)
call.respond(resultList) call.respond(resultList)
} }
get("/output/filter/positive") { get("/output/filter/positive") {
val resultList = resultObjectService.getResultObjecGreaterthanProbability(0.5) ?: call.respond(HttpStatusCode.NotFound) val resultList =
resultObjectService.getResultObjecGreaterthanProbability(0.5)
call.respond(resultList) call.respond(resultList)
} }
get("/output/filter/undecided") { get("/output/filter/undecided") {
val resultList = resultObjectService.getResultObjecEqualsProbability(0.5) ?: call.respond(HttpStatusCode.NotFound) val resultList =
resultObjectService.getResultObjecEqualsProbability(0.5)
call.respond(resultList) call.respond(resultList)
} }
get("/output/after/{dateAfter}") { get("/output/after/{dateAfter}") {
val dateAfter = call.parameters["dateAfter"] ?: error(HttpStatusCode.NotAcceptable) val dateAfter = call.parameters["dateAfter"] ?: error(HttpStatusCode.NotAcceptable)
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE val localDateAfter: LocalDateTime = LocalDateTime.parse(dateAfter)
val localDateAfter : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter) val resultList =
val resultList = resultObjectService.getResultObjectafterDate(localDateAfter) ?: call.respond(HttpStatusCode.NotFound) resultObjectService.getResultObjectafterDate(localDateAfter)
call.respond(resultList) call.respond(resultList)
} }
get("/output/before/{dateBefore}") { get("/output/before/{dateBefore}") {
val dateAfter = call.parameters["dateBefore"] ?: error(HttpStatusCode.NotAcceptable) val dateAfter = call.parameters["dateBefore"] ?: error(HttpStatusCode.NotAcceptable)
val dateTimeFormatter: DateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE val localDateBefore: LocalDateTime = LocalDateTime.parse(dateAfter)
val localDateBefore : LocalDate = LocalDate.parse(dateAfter,dateTimeFormatter) val resultList =
val resultList = resultObjectService.getResultObjectbeforeDate(localDateBefore) ?: call.respond(HttpStatusCode.NotFound) resultObjectService.getResultObjectbeforeDate(localDateBefore)
call.respond(resultList) call.respond(resultList)
} }

View File

@ -2,12 +2,12 @@ package com.kmalbz.database.dao
import org.jetbrains.exposed.dao.id.IntIdTable import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.`java-time`.date import org.jetbrains.exposed.sql.`java-time`.datetime
import java.time.LocalDate import java.time.LocalDateTime
object ResultObjects : IntIdTable() { object ResultObjects : IntIdTable() {
val tag: Column<String> = varchar("tag", 32) val tag: Column<String> = varchar("tag", 32)
val date: Column<LocalDate> = date("date").default(LocalDate.now()) val date: Column<LocalDateTime> = datetime("date").default(LocalDateTime.now())
val probability: Column<Double> = double("probability") val probability: Column<Double> = double("probability")
override val primaryKey = PrimaryKey(id, name = "PK_ResultObject_Id") override val primaryKey = PrimaryKey(id, name = "PK_ResultObject_Id")
} }

View File

@ -1,16 +1,18 @@
package com.kmalbz.database.service package com.kmalbz.database.service
import com.kmalbz.api.model.ApiObject import com.kmalbz.api.model.ApiObject
import java.time.LocalDate import kotlinx.datetime.LocalDateTime
interface IResultObjectService{ interface IResultObjectService{
fun addOne(apiObject: ApiObject) fun addOne(apiObject: ApiObject)
suspend fun getAllResultObjects(): List<ApiObject> suspend fun getAllResultObjects(): List<ApiObject>
suspend fun getCount(): Long
suspend fun getPage(page: Long): List<ApiObject>
suspend fun getResultObjectbyTag(tag: String): ApiObject? suspend fun getResultObjectbyTag(tag: String): ApiObject?
suspend fun getResultObjectbyDate(date: LocalDate): List<ApiObject>? suspend fun getResultObjectbyDate(date: LocalDateTime): List<ApiObject>
suspend fun getResultObjectbeforeDate(date: LocalDate): List<ApiObject>? suspend fun getResultObjectbeforeDate(date: LocalDateTime): List<ApiObject>
suspend fun getResultObjectafterDate(date: LocalDate): List<ApiObject>? suspend fun getResultObjectafterDate(date: LocalDateTime): List<ApiObject>
suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject>? suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject>
suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject>? suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject>
suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject>? suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject>
} }

View File

@ -4,11 +4,12 @@ import com.kmalbz.database.DatabaseFactory.dbQuery
import com.kmalbz.database.model.ResultObject import com.kmalbz.database.model.ResultObject
import com.kmalbz.database.dao.ResultObjects import com.kmalbz.database.dao.ResultObjects
import com.kmalbz.api.model.ApiObject import com.kmalbz.api.model.ApiObject
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.toJavaLocalDateTime
import org.jetbrains.exposed.sql.ResultRow import org.jetbrains.exposed.sql.ResultRow
import org.jetbrains.exposed.sql.select import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.selectAll
import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.transactions.transaction
import java.time.LocalDate
class ResultObjectService : IResultObjectService { class ResultObjectService : IResultObjectService {
@ -26,6 +27,14 @@ class ResultObjectService : IResultObjectService {
ResultObjects.selectAll().map { toResultObject(it) } ResultObjects.selectAll().map { toResultObject(it) }
} }
override suspend fun getCount(): Long = dbQuery {
ResultObjects.selectAll().count()
}
override suspend fun getPage(page: Long): List<ApiObject> = dbQuery {
ResultObjects.selectAll().limit(10,page*10).map { toResultObject(it) }
}
override suspend fun getResultObjectbyTag(tag: String): ApiObject? = dbQuery { override suspend fun getResultObjectbyTag(tag: String): ApiObject? = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.tag eq tag) (ResultObjects.tag eq tag)
@ -33,37 +42,37 @@ class ResultObjectService : IResultObjectService {
.singleOrNull() .singleOrNull()
} }
override suspend fun getResultObjectbyDate(date: LocalDate): List<ApiObject>? = dbQuery { override suspend fun getResultObjectbyDate(date: LocalDateTime): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.date eq date) (ResultObjects.date eq date.toJavaLocalDateTime())
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }
} }
override suspend fun getResultObjectbeforeDate(date: LocalDate): List<ApiObject>? = dbQuery { override suspend fun getResultObjectbeforeDate(date: LocalDateTime): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.date less date) (ResultObjects.date less date.toJavaLocalDateTime())
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }
} }
override suspend fun getResultObjectafterDate(date: LocalDate): List<ApiObject>? = dbQuery { override suspend fun getResultObjectafterDate(date: LocalDateTime): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.date greater date) (ResultObjects.date greater date.toJavaLocalDateTime())
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }
} }
override suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject>? = dbQuery { override suspend fun getResultObjecGreaterthanProbability(probability: Double): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.probability greater probability) (ResultObjects.probability greater probability)
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }
} }
override suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject>? = dbQuery { override suspend fun getResultObjecLessthanProbability(probability: Double): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.probability less probability) (ResultObjects.probability less probability)
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }
} }
override suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject>? = dbQuery { override suspend fun getResultObjecEqualsProbability(probability: Double): List<ApiObject> = dbQuery {
ResultObjects.select { ResultObjects.select {
(ResultObjects.probability eq probability) (ResultObjects.probability eq probability)
}.mapNotNull { toResultObject(it) } }.mapNotNull { toResultObject(it) }

View File

@ -3,8 +3,7 @@ package com.kmalbz.di
import com.kmalbz.database.service.IResultObjectService import com.kmalbz.database.service.IResultObjectService
import com.kmalbz.database.service.ResultObjectService import com.kmalbz.database.service.ResultObjectService
import org.koin.dsl.module import org.koin.dsl.module
import org.koin.experimental.builder.singleBy
val injectionModule = module(createdAtStart = true) { val injectionModule = module(createdAtStart = true) {
singleBy<IResultObjectService,ResultObjectService>() single<IResultObjectService> {ResultObjectService()}
} }