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

Panthers Tiffany Rogers #168

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

Conversation

Tiffany-Rogers-Dev
Copy link

No description provided.

Copy link

@kelsey-steven-ada kelsey-steven-ada left a comment

Choose a reason for hiding this comment

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

Congrats on your first project! 🎉 I’ve added some suggestions & questions, please let me know if there's anything I can clarify ^_^

pp.pprint(HORROR_1)
pp.pprint(FANTASY_1)
pp.pprint(FANTASY_2)
# print("\n-----Wave 01 test data-----")

Choose a reason for hiding this comment

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

Committing changes to this file & the README is no issue for this project, but something to think about going forward is that we generally don't want to commit temporary changes for testing, or changes to files that we don't intend to purposefully share with other folks. This can mean having to be more selective when staging files for commit over being able to use git add .

Comment on lines +122 to +124
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1
assert updated_data["watched"][0]["genre"] == GENRE_1
assert updated_data["watched"][0]["rating"] == RATING_1

Choose a reason for hiding this comment

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

Nice checks for all the movie's data!

Comment on lines +149 to +151
assert updated_data["watched"][1]["title"] == MOVIE_TITLE_1
assert updated_data["watched"][1]["genre"] == GENRE_1
assert updated_data["watched"][1]["rating"] == RATING_1

Choose a reason for hiding this comment

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

Our problem statement doesn't specify what order a movie should be added to the watched list in. If movies were added to the beginning to the list rather than the end, these tests would fail. A more flexible way we could check if a movie is in watched, is to check if the entire movie dictionary exists in the list:

assert HORROR_1 in updated_data["watched"]

When writing tests, we want to check all the relevant data to ensure there weren't unexpected side affects. Since there are other movies in the watchlist and watched lists, we could also add assertions for those:

assert FANTASY_2 in updated_data["watched"]
assert FANTASY_1 in updated_data["watchlist"]

Comment on lines +12 to +13
if not title or not genre or not rating:
return None

Choose a reason for hiding this comment

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

Nice one-liner to validate all the inputs!

In this implementations, the movies variable will be created and allocated space before we know if the inputs are valid. I would recommend flipping the order and placing the validity check first so that movies is only created if it will be needed.


def create_movie(title, genre, rating):
pass
movies = {

Choose a reason for hiding this comment

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

When we pluralize a variable name, that usually means the variable is pointing to a collection holding many objects. If movies isn't a collection of multiple movies, we probably want to give it a singular name to better reflect what it holds.

Comment on lines +73 to +74
for my_movies in my_watched:
cool_movies_watched.append(my_movies)

Choose a reason for hiding this comment

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

Python's list comprehensions give us another option to fill a list from existing data:

# We can read the list comprehension on the right side of the assignment operator as: 
# "For each movie in user_data['watched'] add movie to a new list"
cool_movies_watched = [movie for movie in user_data['watched']]

Comment on lines +76 to +78
for friends_watched in friends:
for friends_movies in friends_watched['watched']:
friends_mediocre_movies.append(friends_movies)

Choose a reason for hiding this comment

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

This doesn't change the function's overall performance, but another option to add values from one list to another is the extend function:

   for friends_watched in friends:
       friends_mediocre_movies.extend(friends_watched['watched')

return unique_movies


def get_friends_unique_watched(user_data):

Choose a reason for hiding this comment

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

The feedback for get_unique_watched applies to this function as well.

for movie in cool_movies_watched:
if not movie in friends_mediocre_movies and movie not in unique_movies:
unique_movies.append(movie)
return unique_movies

Choose a reason for hiding this comment

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

Great approach with nested loops! Another of many possible implementations could use the Set data structure to solve this – if we created a Set that held our user_data["watched"] movies and another Set that held all the movies in our friends' watched lists, then we could take the difference of those sets!

my_movies = set(user_data["watched"])

friend_movies = set()
for friend in user_data["friends"]:
        for movie in friend["watched"]:
                friend_movies.add(movie)

unique_watched_set = my_movies - friend_movies
return list(unique_watched_set)

Comment on lines +95 to +97
for friends_watched in friends:
for friends_movies in friends_watched['watched']:
friends_mediocre_movies.append(friends_movies)

Choose a reason for hiding this comment

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

We have some repeated code in get_unique_watched and here to fill a list with all our friend's movies. How could a helper function reduce this repeated code?

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