Fixed news response, remove page params in rankings and other fixes to filter

v5 v5.4.1
Jéluchu 2 months ago
parent f53ed50bb2
commit a846b2ef4c

@ -82,7 +82,6 @@ data class AnimeData(
/** /**
* Type of the anime. * Type of the anime.
* @see AnimeType for the detail.
*/ */
@SerialName("type") @SerialName("type")
val type: String? = "", val type: String? = "",

@ -227,7 +227,6 @@ fun documentToAnimeTopEntity(doc: Document) = AnimeTopEntity(
airing = doc.getBooleanSafe("airing"), airing = doc.getBooleanSafe("airing"),
type = doc.getStringSafe("type"), type = doc.getStringSafe("type"),
subtype = doc.getStringSafe("subtype"), subtype = doc.getStringSafe("subtype"),
page = doc.getIntSafe("page"),
) )
fun documentToAnimeLastEpisodeEntity(doc: Document) = LastEpisodeData( fun documentToAnimeLastEpisodeEntity(doc: Document) = LastEpisodeData(
@ -252,7 +251,6 @@ fun documentToMangaTopEntity(doc: Document) = MangaTopEntity(
status = doc.getStringSafe("status"), status = doc.getStringSafe("status"),
type = doc.getStringSafe("type"), type = doc.getStringSafe("type"),
subtype = doc.getStringSafe("subtype"), subtype = doc.getStringSafe("subtype"),
page = doc.getIntSafe("page"),
) )
fun documentToPeopleTopEntity(doc: Document) = PeopleTopEntity( fun documentToPeopleTopEntity(doc: Document) = PeopleTopEntity(
@ -262,7 +260,6 @@ fun documentToPeopleTopEntity(doc: Document) = PeopleTopEntity(
familyName = doc.getStringSafe("familyName"), familyName = doc.getStringSafe("familyName"),
image = doc.getStringSafe("image"), image = doc.getStringSafe("image"),
birthday = doc.getStringSafe("birthday"), birthday = doc.getStringSafe("birthday"),
page = doc.getIntSafe("page"),
top = doc.getStringSafe("top"), top = doc.getStringSafe("top"),
) )
@ -272,7 +269,6 @@ fun documentToCharacterTopEntity(doc: Document) = CharacterTopEntity(
nameKanji = doc.getStringSafe("nameKanji"), nameKanji = doc.getStringSafe("nameKanji"),
image = doc.getStringSafe("image"), image = doc.getStringSafe("image"),
top = doc.getStringSafe("top"), top = doc.getStringSafe("top"),
page = doc.getIntSafe("page"),
) )
fun documentToAnimeTypeEntity(doc: Document) = AnimeTypeEntity( fun documentToAnimeTypeEntity(doc: Document) = AnimeTypeEntity(

@ -11,11 +11,9 @@ fun Route.animeEndpoints(
mongoDatabase: MongoDatabase, mongoDatabase: MongoDatabase,
service: AnimeService = AnimeService(mongoDatabase), service: AnimeService = AnimeService(mongoDatabase),
directoryService: DirectoryService = DirectoryService(mongoDatabase), directoryService: DirectoryService = DirectoryService(mongoDatabase),
) { ) = route(Routes.ANIME) {
route(Routes.ANIME) { getToJson(Routes.ID) { service.getAnimeByMalId(call) }
getToJson(Routes.ID) { service.getAnimeByMalId(call) } getToJson(Routes.LAST_EPISODES) { service.getLastEpisodes(call) }
getToJson(Routes.LAST_EPISODES) { service.getLastEpisodes(call) }
}
route(Routes.DIRECTORY) { route(Routes.DIRECTORY) {
getToJson { service.getDirectory(call) } getToJson { service.getDirectory(call) }

@ -7,7 +7,6 @@ import com.jeluchu.core.utils.Collections
import com.jeluchu.core.utils.RssSources import com.jeluchu.core.utils.RssSources
import com.jeluchu.core.utils.RssUrls import com.jeluchu.core.utils.RssUrls
import com.jeluchu.core.utils.parseDataToDocuments import com.jeluchu.core.utils.parseDataToDocuments
import com.jeluchu.features.anime.mappers.documentToAnimeTopEntity
import com.jeluchu.features.news.mappers.documentToNewsEntity import com.jeluchu.features.news.mappers.documentToNewsEntity
import com.jeluchu.features.news.mappers.toNews import com.jeluchu.features.news.mappers.toNews
import com.jeluchu.features.news.models.NewEntity import com.jeluchu.features.news.models.NewEntity
@ -58,7 +57,7 @@ class NewsService(
.find() .find()
.toList() .toList()
val elements = animes.map { documentToAnimeTopEntity(it) } val elements = animes.map { documentToNewsEntity(it) }
call.respond(HttpStatusCode.OK, Json.encodeToString(elements)) call.respond(HttpStatusCode.OK, Json.encodeToString(elements))
} }
} }
@ -93,7 +92,7 @@ class NewsService(
.find() .find()
.toList() .toList()
val elements = animes.map { documentToAnimeTopEntity(it) } val elements = animes.map { documentToNewsEntity(it) }
call.respond(HttpStatusCode.OK, Json.encodeToString(elements)) call.respond(HttpStatusCode.OK, Json.encodeToString(elements))
} }
} }

@ -105,7 +105,13 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse)) call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else { } else {
val animes = animeRanking val animes = animeRanking
.find(Filters.eq("type", type.lowercase())) .find(
Filters.and(
Filters.eq("page", page),
Filters.eq("type", type),
Filters.eq("subtype", filter)
)
)
.skip(skipCount) .skip(skipCount)
.limit(size) .limit(size)
.toList() .toList()
@ -182,7 +188,13 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse)) call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else { } else {
val mangas = mangaRanking val mangas = mangaRanking
.find(Filters.eq("type", type.lowercase())) .find(
Filters.and(
Filters.eq("page", page),
Filters.eq("type", type),
Filters.eq("subtype", filter)
)
)
.skip(skipCount) .skip(skipCount)
.limit(size) .limit(size)
.toList() .toList()
@ -241,7 +253,7 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse)) call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else { } else {
val peoples = peopleRanking val peoples = peopleRanking
.find() .find(Filters.and(Filters.eq("page", page)))
.skip(skipCount) .skip(skipCount)
.limit(size) .limit(size)
.toList() .toList()
@ -300,7 +312,7 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse)) call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else { } else {
val characters = characterRanking val characters = characterRanking
.find() .find(Filters.and(Filters.eq("page", page)))
.skip(skipCount) .skip(skipCount)
.limit(size) .limit(size)
.toList() .toList()

Loading…
Cancel
Save