get count from db layer as well
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2021-08-17 16:09:10 +02:00
parent 4f67c48f7a
commit f46386d465
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
3 changed files with 6 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class OutputServiceRDBServer {
}
get("/output/count") {
call.respond(resultObjectService.getAllResultObjects().size)
call.respond(resultObjectService.getCount())
}
get("/output/page/{page}") {

View File

@ -7,6 +7,7 @@ import java.util.*
interface IResultObjectService{
fun addOne(apiObject: 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 getResultObjectbyDate(date: LocalDate): List<ApiObject>?

View File

@ -27,6 +27,10 @@ class ResultObjectService : IResultObjectService {
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) }
}