Divinelink / scenepeek-android

ScenePeek is an Android Application that provides information about movies, television shows & persons using the TMDB API.
0 stars 0 forks source link

[Credits] Add multiple roles on cast and crew credits #76

Closed Divinelink closed 2 weeks ago

Divinelink commented 2 weeks ago

This pull requests enhances the cast and crew credits by adding multiple roles to people that have such information.

Each actor or crew member in a series might take on multiple roles, with each role potentially having a different episodeCount. To address this, we modified our queries to retrieve all roles, cast and crew information separately, then appropriately matched and appended the correct roles to each individual.

To address any performance issues (especially in series with thousands of cast members and roles) we're using the kotlin's groupBy operator, that associates each role to a castId

val rolesByCastId = database.seriesCastRoleQueries
   .fetchRoles(aggregateCreditId = id)
   .executeAsList()
   .groupBy { it.castId }

This ensures that finding all roles for a given person becomes a negligible-cost operation:

  database
    .seriesCastQueries
    .fetchSeriesCast(id)
    .asFlow()
    .mapToList(dispatcher.io)
    .map { listOfCast ->
      listOfCast
        .map { cast ->
          val roles = rolesByCastId[cast.id] ?: emptyList()
          cast.toEntity(roles = roles)
        }
        .filter { it.roles.isNotEmpty() }
    }

Additionally:

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 83.14607% with 30 lines in your changes missing coverage. Please review.

Project coverage is 77.74%. Comparing base (0a857af) to head (4039044). Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...inelink/feature/details/media/ui/DetailsContent.kt 0.00% 23 Missing :warning:
...core/ui/components/details/cast/CreditsItemCard.kt 89.47% 0 Missing and 2 partials :warning:
...n/com/andreolas/movierama/home/ui/FlatMediaList.kt 0.00% 1 Missing :warning:
...ore/data/details/mapper/entity/CastEntityMapper.kt 83.33% 0 Missing and 1 partial :warning:
...ork/media/mapper/credits/SeriesCreatorApiMapper.kt 0.00% 1 Missing :warning:
.../network/media/model/details/DetailsResponseApi.kt 83.33% 1 Missing :warning:
.../provider/PersonUiStatePreviewParameterProvider.kt 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #76 +/- ## ========================================== + Coverage 77.72% 77.74% +0.01% ========================================== Files 362 361 -1 Lines 8521 8572 +51 Branches 802 801 -1 ========================================== + Hits 6623 6664 +41 - Misses 1591 1603 +12 + Partials 307 305 -2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.