Skip to content

Maple - Kristina Kraft#81

Open
k0axaca wants to merge 11 commits intoAda-C16:masterfrom
k0axaca:master
Open

Maple - Kristina Kraft#81
k0axaca wants to merge 11 commits intoAda-C16:masterfrom
k0axaca:master

Conversation

@k0axaca
Copy link
Copy Markdown

@k0axaca k0axaca commented Sep 17, 2021

No description provided.

Comment thread viewing_party/party.py
Comment on lines +2 to +10
def create_movie(title, genre, rating):
if title and genre and rating:
movie_dict = {}
movie_dict["title"] = title
movie_dict["genre"] = genre
movie_dict["rating"] = rating
return movie_dict
else:
return None
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This works great but you could just return the title. genre, and rating without doing movie_dict = {}

Suggested change
def create_movie(title, genre, rating):
if title and genre and rating:
movie_dict = {}
movie_dict["title"] = title
movie_dict["genre"] = genre
movie_dict["rating"] = rating
return movie_dict
else:
return None
def create_movie(movie_title, genre, rating):
if movie_title == None or genre == None or rating == None:
return None
else:
return {
"title":title,
"genre":genre,
"rating":rating
}```

Comment thread viewing_party/party.py
return None

def add_to_watched(user_data, movie):
if "watched" in user_data.keys():
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great check to see if watched is a key in user_data

Comment thread viewing_party/party.py

return user_data

def add_to_watchlist(user_data, movie):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙌🏽

Comment thread viewing_party/party.py
count += 1
if item["title"] == title:
watched_movie = user_data["watchlist"][count-1]
user_data["watchlist"].remove(watched_movie)
Copy link
Copy Markdown

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 thread viewing_party/party.py
return user_data

# WAVE 2 #
def get_watched_avg_rating(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good implementation!

Comment thread viewing_party/party.py
# use 'max' function to return highest value
# .get() is used to get the value
most_frequent = str(max(frequency_dict, key=frequency_dict.get))
except ValueError:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

great addition of error handling here

Comment thread viewing_party/party.py
return most_frequent

# WAVE 3 #
def get_unique_watched(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙌🏽

Comment thread viewing_party/party.py

return unique_user_list

def get_friends_unique_watched(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙌🏽

Comment thread viewing_party/party.py

# WAVE 4 #
def get_available_recs(user_data):
unique_friend_list = get_friends_unique_watched(user_data)
Copy link
Copy Markdown

@tgoslee tgoslee Sep 21, 2021

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 here

Comment thread viewing_party/party.py
Comment on lines +156 to +158
fav_genre = get_most_watched_genre(user_data)
# returns fav genre, which is a string
unique_friends_watched = get_friends_unique_watched(user_data)
Copy link
Copy Markdown

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

Comment thread viewing_party/party.py

return new_rec

def get_rec_from_favorites(user_data):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🙌🏽

@tgoslee
Copy link
Copy Markdown

tgoslee commented Sep 21, 2021

Great job. I added some comments on refactoring code, use of helper functions, and using the remove method.

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