Lindsay and Hannahs Viewing Party#37
Open
lindsaybolz wants to merge 28 commits into
Open
Conversation
audreyandoy
reviewed
Apr 24, 2023
Contributor
audreyandoy
left a comment
There was a problem hiding this comment.
Great work Lindsay and Hannah! You hit all the learning goals for this project and all tests are passing. You have earned a well-deserved 🟢 grade on this project ✨
I added comments, compliments, and hints on ways to refactor your code.
Keep up the great work! ✨
Comment on lines
+154
to
+159
| expected = { | ||
| "watchlist" : [], | ||
| "watched" : [{"title": MOVIE_TITLE_1, | ||
| "genre": GENRE_1, | ||
| "rating": RATING_1}] | ||
| } |
| # ******************************************************************************************* | ||
| # ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
| # ******************************************************************************************* | ||
| assert updated_data == expected |
Comment on lines
+181
to
+186
| expected = { | ||
| "watchlist" : [ | ||
| FANTASY_1, | ||
| ], | ||
| "watched" : [FANTASY_2, movie_to_watch] | ||
| } |
Comment on lines
+59
to
+60
| assert INTRIGUE_3 in friends_unique_movies | ||
| assert amandas_data == expected |
Comment on lines
+55
to
+59
| # Act | ||
| recommendations = get_new_rec_by_genre(sonyas_data) | ||
|
|
||
| # Assert | ||
| assert len(recommendations) == 0 |
Comment on lines
+122
to
+127
| for friend in user_data["friends"]: | ||
| for movie in friend["watched"]: | ||
| if movie["title"] in friends_unique_watched_titles: | ||
| if movie["title"] not in added_titles: | ||
| friends_unique_watched_movies.append(movie) | ||
| added_titles.append(movie["title"]) |
Contributor
There was a problem hiding this comment.
A helper function that creates single list of all the friend's movies would be helpful in condensing this function a bit.
Comment on lines
+137
to
+148
| def get_available_recs(user_data): | ||
| # create subscriotions, user_watched, and friends_watched lists | ||
| subscriptions = set(user_data["subscriptions"]) | ||
| user_watched_titles = get_user_watched_titles(user_data) | ||
| friends_watched = get_friends_unique_watched(user_data) | ||
|
|
||
| # find the movies that are not in user watched and that are available with subscriptions | ||
| recommended = [] | ||
| for movie in friends_watched: | ||
| if movie['title'] not in user_watched_titles and movie['host'] in subscriptions: | ||
| recommended.append(movie) | ||
| return recommended |
Comment on lines
+157
to
+167
| def get_new_rec_by_genre(user_data): | ||
| # get most freq genere and friends watched. | ||
| most_frequent_genre = get_most_watched_genre(user_data) | ||
| friends_watched = get_friends_unique_watched(user_data) | ||
|
|
||
| # find recommendations if user hasnt watched and genre is most freq | ||
| recommendations = [] | ||
| for movie in friends_watched: | ||
| if movie not in user_data['watched'] and movie['genre'] == most_frequent_genre: | ||
| recommendations.append(movie) | ||
| return recommendations |
| def get_rec_from_favorites(user_data): | ||
| # create favorites and user_watched_titles | ||
| favorites = user_data["favorites"] | ||
| user_watched_titles = [movie['title'] for movie in get_unique_watched(user_data)] |
Contributor
There was a problem hiding this comment.
Awesome work using list comprehension 🔥
Comment on lines
+175
to
+181
| # get recommendations if the movie is in faves and unique user movies | ||
| recommendations = [] | ||
| for movie in favorites: | ||
| if movie['title'] in user_watched_titles: | ||
| recommendations.append(movie) | ||
|
|
||
| return recommendations No newline at end of file |
Contributor
There was a problem hiding this comment.
We could return the list literal from the list comprehension like so:
return [ movie for movie in favorites if movie['title'] in user_watched_titles]
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.