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() {
|
||||
install(ContentNegotiation) {
|
||||
jackson {
|
||||
enable(SerializationFeature.INDENT_OUTPUT)
|
||||
}
|
||||
jackson {}
|
||||
}
|
||||
}
|
||||
@ -25,19 +25,14 @@ class NotesService(override val kodein: Kodein) : KodeinAware {
|
||||
.where { Notes.userId eq userId }
|
||||
.orderBy(Notes.updatedAt.desc())
|
||||
.map { row ->
|
||||
Notes.createEntity(row)
|
||||
}
|
||||
.toList()
|
||||
.map { note ->
|
||||
val tags = db.from(Tags)
|
||||
.select(Tags.name)
|
||||
.where { Tags.noteId eq note.id }
|
||||
.where { Tags.noteId eq row[Notes.id]!! }
|
||||
.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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user