Skip to content

Commit

Permalink
fix: update book requests
Browse files Browse the repository at this point in the history
  • Loading branch information
bayang committed Apr 1, 2022
1 parent 4147ebd commit f0b95e8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/kotlin/io/github/bayang/jelu/dao/BookRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,14 @@ class BookRepository(
}
val tagsList = mutableListOf<Tag>()
book.tags?.forEach {
val tagEntity: Tag? = findTagsByName(it.name.trim()).firstOrNull()
// first try to find exact match by id
val tagEntity: Tag? = if (it.id != null) {
findTagById(it.id)
}
// if no id provided or research by id doesn't return anything try to find by name
else {
findTagsByName(it.name.trim()).firstOrNull()
}
if (tagEntity != null) {
tagsList.add(tagEntity)
} else {
Expand Down

0 comments on commit f0b95e8

Please sign in to comment.