From 1433bca666e4e6b644ab9e0fa009f96c48f3042d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9luchu?= Date: Mon, 13 Jan 2025 20:41:53 +0100 Subject: [PATCH] Fixed images in directory type and seasonal --- .../features/anime/mappers/AnimeMappers.kt | 27 ++++++++----------- .../anime/services/DirectoryService.kt | 5 ++-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt b/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt index d0046ba..7cacb7b 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt @@ -14,22 +14,6 @@ import org.bson.Document import java.time.ZonedDateTime import java.time.format.DateTimeFormatter -fun documentToAnimeDirectoryEntity(doc: Document) = AnimeDirectoryEntity( - rank = doc.getIntSafe("rank"), - year = doc.getIntSafe("year"), - url = doc.getStringSafe("url"), - malId = doc.getIntSafe("malId"), - type = doc.getStringSafe("type"), - score = doc.getStringSafe("score"), - title = doc.getStringSafe("title"), - status = doc.getStringSafe("status"), - season = doc.getStringSafe("season"), - poster = doc.getStringSafe("poster"), - airing = doc.getBooleanSafe("airing"), - genres = doc.getListSafe("genres"), - episodesCount = doc.getIntSafe("episodesCount") -) - fun documentToMoreInfoEntity(doc: Document): MoreInfoEntity { return MoreInfoEntity( id = doc.getObjectId("_id").toString(), @@ -295,6 +279,17 @@ fun documentToAnimeTypeEntity(doc: Document) = AnimeTypeEntity( episodes = doc.getListSafe("episodes").size ) +fun documentToAnimeDirectoryEntity(doc: Document) = AnimeTypeEntity( + score = doc.getString("score"), + malId = doc.getIntSafe("malId"), + year = doc.getIntSafe("year"), + season = doc.getStringSafe("season"), + type = doc.getStringSafe("type"), + title = doc.getStringSafe("title"), + image = doc.getStringSafe("image"), + episodes = doc.getListSafe("episodes").size +) + fun documentToLastEpisodesEntity(doc: Document) = EpisodeEntity( number = doc.getIntSafe("number"), title = doc.getStringSafe("title"), diff --git a/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt b/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt index e5bc006..a9aa189 100644 --- a/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt +++ b/src/main/kotlin/com/jeluchu/features/anime/services/DirectoryService.kt @@ -9,6 +9,7 @@ import com.jeluchu.core.models.ErrorResponse import com.jeluchu.core.models.PaginationResponse import com.jeluchu.core.utils.Collections import com.jeluchu.core.utils.TimerKey +import com.jeluchu.features.anime.mappers.documentToAnimeDirectoryEntity import com.jeluchu.features.anime.mappers.documentToAnimeTypeEntity import com.mongodb.client.MongoDatabase import com.mongodb.client.model.Filters @@ -75,7 +76,7 @@ class DirectoryService( .limit(size) .toList() - val responseItems = elements.map { documentToAnimeTypeEntity(it) } + val responseItems = elements.map { documentToAnimeDirectoryEntity(it) } val response = PaginationResponse( page = page, data = responseItems, @@ -137,7 +138,7 @@ class DirectoryService( .limit(size) .toList() - val responseItems = elements.map { documentToAnimeTypeEntity(it) } + val responseItems = elements.map { documentToAnimeDirectoryEntity(it) } val response = PaginationResponse( page = page, data = responseItems,