Merge branch 'optimizations/notes-endpoint-perf' into feature/notes-table
This commit is contained in:
commit
ebd647a1a9
@ -7,8 +7,6 @@ import io.ktor.jackson.*
|
|||||||
|
|
||||||
fun Application.contentNegotiationFeature() {
|
fun Application.contentNegotiationFeature() {
|
||||||
install(ContentNegotiation) {
|
install(ContentNegotiation) {
|
||||||
jackson {
|
jackson {}
|
||||||
enable(SerializationFeature.INDENT_OUTPUT)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,19 +25,14 @@ class NotesService(override val kodein: Kodein) : KodeinAware {
|
|||||||
.where { Notes.userId eq userId }
|
.where { Notes.userId eq userId }
|
||||||
.orderBy(Notes.updatedAt.desc())
|
.orderBy(Notes.updatedAt.desc())
|
||||||
.map { row ->
|
.map { row ->
|
||||||
Notes.createEntity(row)
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
.map { note ->
|
|
||||||
val tags = db.from(Tags)
|
val tags = db.from(Tags)
|
||||||
.select(Tags.name)
|
.select(Tags.name)
|
||||||
.where { Tags.noteId eq note.id }
|
.where { Tags.noteId eq row[Notes.id]!! }
|
||||||
.map { it[Tags.name]!! }
|
.map { it[Tags.name]!! }
|
||||||
.toList()
|
|
||||||
|
|
||||||
val updatedAt = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(note.updatedAt)
|
val updatedAt = DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(row[Notes.updatedAt]!!)
|
||||||
|
|
||||||
NotesDTO(note.title, tags, updatedAt)
|
NotesDTO(row[Notes.title]!!, tags, updatedAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getNoteIdFromUserIdAndTitle(userId: Int, noteTitle: String): Int? = db.from(Notes)
|
fun getNoteIdFromUserIdAndTitle(userId: Int, noteTitle: String): Int? = db.from(Notes)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user