Skip to content

Commit

Permalink
refactor: filter user watched cast to exclude voiced characters (#102)
Browse files Browse the repository at this point in the history
* refactor: filter user watched cast to exclude voiced characters

* chore: update CHANGELOG to include filter for voiced characters (#101)

* Update CHANGELOG.md

* Update CHANGELOG.md for version 1.10.5, adding a fix for filtering voiced characters. Previous version 1.10.4 included enhancements for login and user network activities.

---------

Co-authored-by: João Pedro Alves <joaopealves.dev@gmail.com>
  • Loading branch information
lui7henrique and eulixir authored Jan 23, 2025
1 parent a716f2f commit 80876e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Added
## 1.10.5

### Fixed

- Filter characters that are voiced [(#102)](https://github.com/plotwist-app/plotwist-backend/pull/102)

## 1.10.4

- Make possible login with email or username [(#101)](https://github.com/plotwist-app/plotwist-backend/pull/101)
- Add user network activities [(#100)](https://github.com/plotwist-app/plotwist-backend/pull/100)

### Changed

- Filter characters that are voiced [(#102)](https://github.com/plotwist-app/plotwist-backend/pull/102)

## 1.10.4

### Fixed
Expand Down
9 changes: 8 additions & 1 deletion src/domain/services/user-stats/get-user-watched-cast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ export async function getUserWatchedCastService({
)

const flattedCast = watchedItemsCast.flat()
const filteredCast = flattedCast.filter(
actor =>
actor.known_for_department === 'Acting' &&
// Filter characters that are voiced
['(', ')'].every(char => !actor.character.includes(char))
)

const totalWatchedItems = watchedItems.length

const actorCount: Record<
number,
{ name: string; count: number; profilePath: string | null }
> = {}

for (const actor of flattedCast) {
for (const actor of filteredCast) {
const actorId = actor.id

if (!actorCount[actorId]) {
Expand Down

0 comments on commit 80876e9

Please # to comment.