From 6e4fa89e85a031f9169a008aa49488a12566ad7c Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Fri, 24 Apr 2020 00:20:28 +0200 Subject: [PATCH 1/2] Limit object creation in getNotes --- api/src/services/NotesService.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/api/src/services/NotesService.kt b/api/src/services/NotesService.kt index 1f31991..f89c829 100644 --- a/api/src/services/NotesService.kt +++ b/api/src/services/NotesService.kt @@ -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) From 1e3a34128989aa84a11fdb238f42aff862a4ffa4 Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Fri, 24 Apr 2020 02:08:42 +0200 Subject: [PATCH 2/2] Disable json pretty formating --- api/src/features/ContentNegotiationFeature.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/api/src/features/ContentNegotiationFeature.kt b/api/src/features/ContentNegotiationFeature.kt index 3b91178..8906914 100644 --- a/api/src/features/ContentNegotiationFeature.kt +++ b/api/src/features/ContentNegotiationFeature.kt @@ -7,8 +7,6 @@ import io.ktor.jackson.* fun Application.contentNegotiationFeature() { install(ContentNegotiation) { - jackson { - enable(SerializationFeature.INDENT_OUTPUT) - } + jackson {} } } \ No newline at end of file