-
Notifications
You must be signed in to change notification settings - Fork 97
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
Maple Detroit #91
base: master
Are you sure you want to change the base?
Maple Detroit #91
Conversation
@@ -0,0 +1,182 @@ | |||
|
|||
def create_movie(title, genre, rating): |
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.
🙌🏽
else: | ||
return None | ||
|
||
def add_to_watched(user_data, 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.
🙌🏽
user_data["watched"].append(movie) | ||
return user_data | ||
|
||
def add_to_watchlist(user_data, 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.
🙌🏽
#if title and genre and rating: | ||
# movie_dict = {"title": title, | ||
# "genre" :genre, | ||
# "rating": rating, | ||
# } | ||
# return movie_dict | ||
# else: | ||
# return None | ||
|
||
|
||
# def add_to_watched(user_data, movie): | ||
# watched = user_data["watched"] | ||
# if movie: | ||
# watched.append(movie) | ||
# else: | ||
# watched = [] | ||
# 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.
When you are finished with a project/branch you would remove unused code when making a pull request
if title in movie["title"]: | ||
watch_list.remove(movie) | ||
watched.append(movie) | ||
return user_data#def create_movie(title,genre,rating): |
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.
return user_data#def create_movie(title,genre,rating): | |
return user_data |
|
||
for movie in watch_list: | ||
if title in movie["title"]: | ||
watch_list.remove(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.
even though remove works great here, be careful using it in a for loop. It can cause side effects. Here is a link that explains it more with examples https://thispointer.com/python-remove-elements-from-a-list-while-iterating/
# avg_rating = 0.0 | ||
# rating_sum = 0 | ||
# for i in range (len(user_data["watched"])): | ||
# rating_sum += user_data["watched"][i]["rating"] | ||
# #calculating | ||
# rating_sum/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.
remove previous attempt
total_rating = 0 | ||
if len(user_data["watched"]) == 0: | ||
return 0 | ||
else: | ||
for movie in user_data["watched"]: | ||
total_rating += movie["rating"] | ||
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.
good implementation
|
||
|
||
|
||
def get_most_watched_genre(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 a frequency map here and the use of the max method
|
||
# Wave 3 | ||
|
||
def 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.
🙌🏽
|
||
for watched_list in user_data["friends"]: | ||
for movie in watched_list["watched"]: | ||
if movie not in user_data["watched"] and movie not in movies_friends_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.
great compound statement here
|
||
#Wave 4 | ||
|
||
def get_available_recs(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.
this is a good implementation. Think about how you could of use one of your previously created functions get_friends_unique_watched(user_data) here to save some lines of code.
if movie["host"] in host: | ||
if movie not in rec_list: |
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.
you could also use a compound statement here as you did in the previous function like if movie["host"] not in user_title and movie not in rec_list:
user_most_watched_genre = get_most_watched_genre(user_data) | ||
friends_unique_list = 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
|
||
|
||
def get_rec_from_favorites(user_data): | ||
user_unique_list = 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.
great use of helper function
# def get_new_rec_by_genre(user_data): | ||
# recommended_genre = [] | ||
# new_list = [] | ||
# fave_genre = get_most_watched_genre(user_data) | ||
# for movie in user_data["friends"]: | ||
# for i in movie["watched"]: | ||
# new_list.append(i) | ||
# for movie in new_list: | ||
# if movie["genre"] == fave_genre: | ||
# recommended_genre.append(movie) | ||
# return recommended_genre | ||
# def get_rec_from_favorites(user_data): | ||
# recs_from_faves = [] | ||
# unique_watched_list = get_unique_watched(user_data) | ||
# faves = user_data["favorites"] | ||
# for movie in unique_watched_list: | ||
# if movie in faves: | ||
# recs_from_faves.append(movie) | ||
# return recs_from_faves | ||
|
||
# def get_new_rec_by_genre: |
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.
remove other attempts from code to clean it up
Great job! I added some comments on refactoring your code, removing unused code, and the use of helper functions. |
No description provided.