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 Detroit #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

Detroit-the-Dev
Copy link

No description provided.

@@ -0,0 +1,182 @@

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.

🙌🏽

else:
return None

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.

🙌🏽

user_data["watched"].append(movie)
return user_data

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.

🙌🏽

Comment on lines +31 to +47
#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
Copy link

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):
Copy link

Choose a reason for hiding this comment

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

Suggested change
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)
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 +54 to +59
# 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"])
Copy link

Choose a reason for hiding this comment

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

remove previous attempt

Comment on lines +60 to +66
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"])
Copy link

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):
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 a frequency map here and the use of the max method


# Wave 3

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.

🙌🏽


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:
Copy link

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):
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. 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.

Comment on lines +134 to +135
if movie["host"] in host:
if movie not in rec_list:
Copy link

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:

Comment on lines +142 to +143
user_most_watched_genre = get_most_watched_genre(user_data)
friends_unique_list = 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 functions



def get_rec_from_favorites(user_data):
user_unique_list = 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.

great use of helper function

Comment on lines +162 to +182
# 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:
Copy link

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

@tgoslee
Copy link

tgoslee commented Sep 21, 2021

Great job! I added some comments on refactoring your code, removing unused code, and the use of 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