-
Notifications
You must be signed in to change notification settings - Fork 81
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
Zoisite: Jessica Anderson #68
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.
Your code is looking really great, Jessica! You leverage helper functions really well and I can tell you have really absorbed this material. I left just a few suggestions but overall this is definitely a GREEN!
movie = { "title" : title, | ||
"genre" : genre, | ||
"rating" : rating} | ||
return movie |
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.
This looks great! If you want to pare it down a little more, you wouldn't even need to make a movie and then return it! You could just return the movie as is! (return {"title": title, "genre": genre... etc.)
if movie["title"] == title: | ||
user_data["watchlist"].remove(movie) | ||
user_data["watched"].append(movie) | ||
break |
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 use of the break statement!
user_data["watched"].append(movie) | ||
break | ||
|
||
return 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.
These three methods are great!
def get_watched_avg_rating(user_data): | ||
|
||
if not user_data["watched"]: | ||
return 0.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.
Nice guard clause!
return 0.0 | ||
else: | ||
total_rating = sum(movie["rating"] for movie in user_data["watched"]) | ||
return total_rating / len(user_data["watched"]) |
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.
While there's no official ruling one way or the other, I like to remove the else statement entirely if it isn't necessary. This is especially true when the if portion of the conditional is a guard clause.
friend_movies = [] | ||
for friend in user_data["friends"]: | ||
for movie in friend["watched"]: | ||
friend_movies.append(movie) |
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.
Once again, you could add a quick check to see if the movie is already in "friend_movies" or not. This prevents duplicates which could avoid the compound conditional below!
|
||
# ----------------------------------------- | ||
# ------------- WAVE 4 -------------------- | ||
# ----------------------------------------- | ||
|
||
def get_available_recs(user_data): | ||
movies_not_watched = get_friends_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.
Great use of helper functions here!
if movie["host"] in sub_list: | ||
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.
This looks really good!
for movie in not_watched_yet: | ||
if movie["genre"] == fav_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.
Really well done with this function too! I love the way you made each part its own call to a function. And once again, your instinct to use helper functions is great!
if movie in favorites: | ||
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.
Short and sleek! This function leverages helper functions well again.
No description provided.