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.
* @see AnimeType for the detail.
*/
@SerialName("type")
val type: String? = "",

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

@ -11,11 +11,9 @@ fun Route.animeEndpoints(
mongoDatabase: MongoDatabase,
service: AnimeService = AnimeService(mongoDatabase),
directoryService: DirectoryService = DirectoryService(mongoDatabase),
) {
route(Routes.ANIME) {
getToJson(Routes.ID) { service.getAnimeByMalId(call) }
getToJson(Routes.LAST_EPISODES) { service.getLastEpisodes(call) }
}
) = route(Routes.ANIME) {
getToJson(Routes.ID) { service.getAnimeByMalId(call) }
getToJson(Routes.LAST_EPISODES) { service.getLastEpisodes(call) }
route(Routes.DIRECTORY) {
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.RssUrls
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.toNews
import com.jeluchu.features.news.models.NewEntity
@ -58,7 +57,7 @@ class NewsService(
.find()
.toList()
val elements = animes.map { documentToAnimeTopEntity(it) }
val elements = animes.map { documentToNewsEntity(it) }
call.respond(HttpStatusCode.OK, Json.encodeToString(elements))
}
}
@ -93,7 +92,7 @@ class NewsService(
.find()
.toList()
val elements = animes.map { documentToAnimeTopEntity(it) }
val elements = animes.map { documentToNewsEntity(it) }
call.respond(HttpStatusCode.OK, Json.encodeToString(elements))
}
}

@ -105,7 +105,13 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else {
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)
.limit(size)
.toList()
@ -182,7 +188,13 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else {
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)
.limit(size)
.toList()
@ -241,7 +253,7 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else {
val peoples = peopleRanking
.find()
.find(Filters.and(Filters.eq("page", page)))
.skip(skipCount)
.limit(size)
.toList()
@ -300,7 +312,7 @@ class RankingsService(
call.respond(HttpStatusCode.OK, Json.encodeToString(paginationResponse))
} else {
val characters = characterRanking
.find()
.find(Filters.and(Filters.eq("page", page)))
.skip(skipCount)
.limit(size)
.toList()

Loading…
Cancel
Save