-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add total unseen minutes (missed episodes)
- Loading branch information
Showing
16 changed files
with
148 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/kotlin/fr/shikkanime/converters/member/MemberToRefreshMemberDtoConverter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fr.shikkanime.converters.member | ||
|
||
import com.google.inject.Inject | ||
import fr.shikkanime.converters.AbstractConverter | ||
import fr.shikkanime.dtos.AnimeDto | ||
import fr.shikkanime.dtos.MissedAnimeDto | ||
import fr.shikkanime.dtos.PageableDto | ||
import fr.shikkanime.dtos.mappings.EpisodeMappingDto | ||
import fr.shikkanime.dtos.member.RefreshMemberDto | ||
import fr.shikkanime.entities.Member | ||
import fr.shikkanime.services.MemberFollowAnimeService | ||
import fr.shikkanime.services.MemberFollowEpisodeService | ||
|
||
class MemberToRefreshMemberDtoConverter : AbstractConverter<Member, RefreshMemberDto>() { | ||
@Inject | ||
private lateinit var memberFollowAnimeService: MemberFollowAnimeService | ||
|
||
@Inject | ||
private lateinit var memberFollowEpisodeService: MemberFollowEpisodeService | ||
|
||
override fun convert(from: Member): RefreshMemberDto { | ||
val page = 1 | ||
val limit = 9 | ||
|
||
val missedAnimesPageable = memberFollowAnimeService.findAllMissedAnimes(from, page, limit) | ||
val followedAnimesPageable = memberFollowAnimeService.findAllFollowedAnimes(from, page, limit) | ||
val followedEpisodesPageable = memberFollowEpisodeService.findAllFollowedEpisodes(from, page, limit) | ||
val (totalDuration, totalUnseenDuration) = memberFollowEpisodeService.getSeenAndUnseenDuration(from) | ||
|
||
val missedAnimeDtos = missedAnimesPageable.data.map { tuple -> | ||
MissedAnimeDto( | ||
convert(tuple[0], AnimeDto::class.java), | ||
tuple[1] as Long | ||
) | ||
} | ||
|
||
return RefreshMemberDto( | ||
missedAnimes = PageableDto( | ||
data = missedAnimeDtos, | ||
page = missedAnimesPageable.page, | ||
limit = missedAnimesPageable.limit, | ||
total = missedAnimesPageable.total, | ||
), | ||
followedAnimes = PageableDto.fromPageable(followedAnimesPageable, AnimeDto::class.java), | ||
followedEpisodes = PageableDto.fromPageable(followedEpisodesPageable, EpisodeMappingDto::class.java), | ||
totalDuration = totalDuration, | ||
totalUnseenDuration = totalUnseenDuration, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/fr/shikkanime/dtos/member/RefreshMemberDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fr.shikkanime.dtos.member | ||
|
||
import fr.shikkanime.dtos.AnimeDto | ||
import fr.shikkanime.dtos.MissedAnimeDto | ||
import fr.shikkanime.dtos.PageableDto | ||
import fr.shikkanime.dtos.mappings.EpisodeMappingDto | ||
|
||
data class RefreshMemberDto( | ||
val missedAnimes: PageableDto<MissedAnimeDto>, | ||
val followedAnimes: PageableDto<AnimeDto>, | ||
val followedEpisodes: PageableDto<EpisodeMappingDto>, | ||
val totalDuration: Long, | ||
val totalUnseenDuration: Long, | ||
) |
2 changes: 1 addition & 1 deletion
2
...ain/kotlin/fr/shikkanime/dtos/TokenDto.kt → ...lin/fr/shikkanime/dtos/member/TokenDto.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package fr.shikkanime.dtos | ||
package fr.shikkanime.dtos.member | ||
|
||
import io.ktor.server.auth.* | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/kotlin/fr/shikkanime/controllers/api/AbstractControllerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/test/kotlin/fr/shikkanime/controllers/api/MemberControllerTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters