Skip to content
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 - Min #97

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Maple - Min #97

wants to merge 5 commits into from

Conversation

Eatmine
Copy link

@Eatmine Eatmine commented Sep 17, 2021

No description provided.

@@ -0,0 +1,259 @@
#Wave_One part 1
def create_movie (title, genre, rating):
Copy link

Choose a reason for hiding this comment

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

🙌🏽

return None

#Wave_One part 2
def add_to_watched(user_data, movie):
Copy link

Choose a reason for hiding this comment

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

🙌🏽


#Wave_One part 3

def add_to_watchlist(user_data, movie):
Copy link

Choose a reason for hiding this comment

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

🙌🏽

if movie["title"] == title:

user_data["watched"].append(movie)
user_data["watchlist"].remove(movie)
Copy link

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/

Comment on lines +42 to +43


Copy link

Choose a reason for hiding this comment

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

remove extra spacing


#Wave_TWO Part 1

def get_watched_avg_rating(user_data):
Copy link

Choose a reason for hiding this comment

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

great implementation!

if "genre" in movie_genre:
most_populare_genre.append(movie_genre["genre"])
most_common = max(most_populare_genre, key = most_populare_genre.count)
print (most_common)
Copy link

Choose a reason for hiding this comment

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

remove print statement from debugging

Comment on lines +72 to +87
#Completed using a dict but wasn't my first choice
# def get_most_watched_genre(user_data):
# most_popular_genre = {}
# if len(user_data["watched"]) == 0:
# return None
# for movie_genre in user_data["watched"]:
# if movie_genre ["genre"] in most_popular_genre:
# most_popular_genre[movie_genre["genre"]] += 1

# else:
# most_popular_genre[movie_genre["genre"]] = 1

# max_value_genre=max(most_popular_genre, key= most_popular_genre.get)
# return max_value_genre

# # https://www.programiz.com/python-programming/methods/built-in/max
Copy link

Choose a reason for hiding this comment

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

if this isn't the way you want to implement it then you can remove this commented code

friend_movie_set = set()
for movie in user_watched:
user_movie_set.add(movie["title"])
print(user_movie_set)
Copy link

Choose a reason for hiding this comment

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

remove print


#Wave_Three Part 1

def get_unique_watched(user_data):
Copy link

Choose a reason for hiding this comment

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

Nice use of sets

friend_movie_set = set()
for movie in user_watched:
user_movie_set.add(movie["title"])
print(user_movie_set)
Copy link

Choose a reason for hiding this comment

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

remove print


def get_available_recs(user_data):
users_subscription = user_data["subscriptions"]
friends_unique_movies = get_friends_unique_watched(user_data)
Copy link

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

for movies_watched in friends_movie_list:
if movies_watched["host"] in users_subscription and movies_watched not in movie_subscription:
movie_subscription.append(movies_watched)
print(movie_subscription)
Copy link

Choose a reason for hiding this comment

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

remove print




def get_available_recs(user_data):
Copy link

@tgoslee tgoslee Sep 20, 2021

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. I want to offer a suggestion that uses fewer lines of code.

def get_available_recs(user_data): recommended_movies = [] friends_unique_watched = get_friends_unique_watched(user_data) for movie in friends_unique_watched: if movie["host"] in user_data["subscriptions"]: recommended_movies.append(movie) return recommended_movies

Comment on lines +155 to +188
def get_available_recs(user_data):
users_subscription = user_data["subscriptions"]
friends_unique_movies = get_friends_unique_watched(user_data)
users_friends = user_data["friends"]
users_friends_watched_movie = user_data["friends"]


friends_movie_list = []
for watched_movies in users_friends:


for movies in watched_movies["watched"]:
friends_movie_list.append(movies)

movie_subscription = []
for movies_watched in friends_movie_list:
if movies_watched["host"] in users_subscription and movies_watched not in movie_subscription:
movie_subscription.append(movies_watched)
print(movie_subscription)


user_title =[]
for watched_movie in user_data["watched"]:
user_title.append(watched_movie["title"])


recommendations =[]

if not user_data["watched"]:
return movie_subscription
for movie in movie_subscription:
if movie["title"] not in user_title:
recommendations.append(movie)
return recommendations
Copy link

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 but I wanted to offer a solution that uses less lines of code

Suggested change
def get_available_recs(user_data):
users_subscription = user_data["subscriptions"]
friends_unique_movies = get_friends_unique_watched(user_data)
users_friends = user_data["friends"]
users_friends_watched_movie = user_data["friends"]
friends_movie_list = []
for watched_movies in users_friends:
for movies in watched_movies["watched"]:
friends_movie_list.append(movies)
movie_subscription = []
for movies_watched in friends_movie_list:
if movies_watched["host"] in users_subscription and movies_watched not in movie_subscription:
movie_subscription.append(movies_watched)
print(movie_subscription)
user_title =[]
for watched_movie in user_data["watched"]:
user_title.append(watched_movie["title"])
recommendations =[]
if not user_data["watched"]:
return movie_subscription
for movie in movie_subscription:
if movie["title"] not in user_title:
recommendations.append(movie)
return recommendations
def get_available_recs(user_data):
recommended_movies = []
friends_unique_watched = get_friends_unique_watched(user_data)
for movie in friends_unique_watched:
if movie["host"] in user_data["subscriptions"]:
recommended_movies.append(movie)
return recommended_movies

#Wave 5 Part 1


def get_new_rec_by_genre(user_data):
Copy link

Choose a reason for hiding this comment

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

Good implementation and use of helper functions. How could you also use get_friends_unique_watched(user_data)?

Comment on lines +237 to +255
# for friends in users_friends: # {'watched': [{'title': 'Title A', 'host': 'Service A'}, {'title': 'Title C', 'host': 'Service C'}]}
# for friends in (friends["watched"]): #{'title': 'Title A', 'host': 'Service A'} --> friends_movies
# if movie["host"] and movie["title"]:
# friends_movie_list.append(movie["watched"])
# # print(m)
# # print(friends_movie_list)
# return friends_movie_list





# users_movie = user_data["watched"]
# users_friends = user_data["friends"]
# users_subscription = user_data["subscriptions"]
# recommended_movie_list = []
# friends_movies_list = []
# friends_movies_list1 = []
# final_recommendations = []
Copy link

Choose a reason for hiding this comment

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

remove code once you are done testing/debugging



#wave 5 Part 2
def get_rec_from_favorites(user_data):
Copy link

Choose a reason for hiding this comment

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

what helper functions could you also use here?

@tgoslee
Copy link

tgoslee commented Sep 20, 2021

Great job! I like how you thought through alternative ways to approach the functions. I added comments on refactoring your code, removing unused code, and the use of the helper functions.

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.

2 participants