-
Notifications
You must be signed in to change notification settings - Fork 632
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
Lindsay and Hannahs Viewing Party #37
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! ✨
expected = { | ||
"watchlist" : [], | ||
"watched" : [{"title": MOVIE_TITLE_1, | ||
"genre": GENRE_1, | ||
"rating": RATING_1}] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# ******************************************************************************************* | ||
# ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
# ******************************************************************************************* | ||
assert updated_data == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
expected = { | ||
"watchlist" : [ | ||
FANTASY_1, | ||
], | ||
"watched" : [FANTASY_2, movie_to_watch] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
assert INTRIGUE_3 in friends_unique_movies | ||
assert amandas_data == expected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
# Act | ||
recommendations = get_new_rec_by_genre(sonyas_data) | ||
|
||
# Assert | ||
assert len(recommendations) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A helper function that creates single list of all the friend's movies would be helpful in condensing this function a bit.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
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)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work using list comprehension 🔥
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]
No description provided.