Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Nov 10, 2024

Conversation

Divinelink
Copy link
Owner

@Divinelink Divinelink commented Nov 10, 2024

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:

  • Added the role on the Known For section for each person
  • Added Jetpack screenshot tests library

@Divinelink Divinelink self-assigned this Nov 10, 2024
Copy link

codecov bot commented Nov 10, 2024

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 ⚠️
...core/ui/components/details/cast/CreditsItemCard.kt 89.47% 0 Missing and 2 partials ⚠️
...n/com/andreolas/movierama/home/ui/FlatMediaList.kt 0.00% 1 Missing ⚠️
...ore/data/details/mapper/entity/CastEntityMapper.kt 83.33% 0 Missing and 1 partial ⚠️
...ork/media/mapper/credits/SeriesCreatorApiMapper.kt 0.00% 1 Missing ⚠️
.../network/media/model/details/DetailsResponseApi.kt 83.33% 1 Missing ⚠️
.../provider/PersonUiStatePreviewParameterProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Divinelink Divinelink merged commit 2a50700 into main Nov 10, 2024
4 checks passed
@Divinelink Divinelink deleted the feature/enhance-person-roles branch November 10, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant