Skip to content

C22- Phoenix - Astry Brana and Amber Edwards#2

Open
Msambere wants to merge 12 commits intoAda-C22:mainfrom
SpectreKitty:main
Open

C22- Phoenix - Astry Brana and Amber Edwards#2
Msambere wants to merge 12 commits intoAda-C22:mainfrom
SpectreKitty:main

Conversation

@Msambere
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@anselrognlie anselrognlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Please review my comments, and let me know if you have any questions. Slack, our next 1:1, or office hours are preferred (rather than replying to my comments in GitHub) as I don't have email notifications turned on. Nice job!

# Assert
assert len(updated_data["watchlist"]) == 0
assert len(updated_data["watched"]) == 1
assert updated_data["watched"][-1]["title"] == MOVIE_TITLE_1
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's probably the case that if the title is correct, the rest of the data is as well, we should check all three pieces of data to be sure. We can either do this by checking them individually, or we could make a movie dictionary instance to compare.

# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 2
assert updated_data["watched"][-1]["title"] == movie_to_watch["title"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again, we can check all of the values of the movie. And while your implementation does put the watched movie at the end of the list, that wasn't explicitly specified. As a result, an in check using a full movie might better match the specification, since that won't care where in the watched list the movie ends up.

It would probably also be good to ensure that the movie left in the watchlist is the movie we expect, and that the other movie that started in the watched is still there.

Comment on lines +58 to +60
assert FANTASY_4 in friends_unique_movies
assert HORROR_1 in friends_unique_movies
assert INTRIGUE_3 in friends_unique_movies
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great way to check tht the three expected movies are there without worrying about at what position each ended up.


# Assert
assert len(friends_unique_movies) == 3
#assert desired movies on in list
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Put a space after the # in the comment (minor typo in the comment itself?)

    # assert desired movies on in list

Comment on lines +56 to +60
# Act
recommendations = get_new_rec_by_genre(sonyas_data)

# Assert
assert len(recommendations) == 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This test needed both the act and the assert.

recommendations = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
if movie["host"] in user_data["subscriptions"] and movie not in user_data["watched"] and movie not in recommendations:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we started with the movies only watched by friends (get_friends_unique_watched ), we could avoid the check against the movies the user has watched. The code would also be simpler, since most of the looping is also already done in the helper.

Comment on lines +98 to +99
if not user_data["watched"] or not user_data["friends"]:
return recommendations
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without these checks, the logic would return the desired [] result if the user hadn't watched any movies, or had no friends that watched movies.

Comment on lines +101 to +102
most_watched_genre = get_most_watched_genre(user_data)
friend_unique_watched = get_friends_unique_watched(user_data)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Great use of functions written for previous waves. All we have left to do is filter the friends movies by the user's preferred genre.

Comment on lines +104 to +106
for movie in friend_unique_watched:
if movie["genre"] == most_watched_genre:
recommendations.append(movie)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be an ideal case to use a list comprehension.

    recommendations = [movie for movie in friend_unique_watched if movie["genre"] == most_watched_genre]

Comment on lines +120 to +123
if movie in friend["watched"] and movie in recommendations:
recommendations.remove(movie)
elif movie not in friend["watched"] and movie not in recommendations:
recommendations.append(movie)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 The two checks here could result in different results depending on which friend is the final one iterated over. If the final friend has watched the user movie, it would be removed (if a previous friend had resulted in adding it), but if the final friend hasn't watched the movie, it could be added in (even if an earlier friend had watched it).

Instead of dealing with uniquing logic again here, we could use one of our earlier wave functions to start from a list of movies only watched by the user.

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.

3 participants