Skip to content

Commit

Permalink
Fixed images in directory type and seasonal
Browse files Browse the repository at this point in the history
  • Loading branch information
jeluchu committed Jan 13, 2025
1 parent 78f0af1 commit 1433bca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
27 changes: 11 additions & 16 deletions src/main/kotlin/com/jeluchu/features/anime/mappers/AnimeMappers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>("genres"),
episodesCount = doc.getIntSafe("episodesCount")
)

fun documentToMoreInfoEntity(doc: Document): MoreInfoEntity {
return MoreInfoEntity(
id = doc.getObjectId("_id").toString(),
Expand Down Expand Up @@ -295,6 +279,17 @@ fun documentToAnimeTypeEntity(doc: Document) = AnimeTypeEntity(
episodes = doc.getListSafe<Document>("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<Document>("episodes").size
)

fun documentToLastEpisodesEntity(doc: Document) = EpisodeEntity(
number = doc.getIntSafe("number"),
title = doc.getStringSafe("title"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1433bca

Please sign in to comment.