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

Final changes for the project #9

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

Conversation

smchavan
Copy link

@smchavan smchavan commented Nov 9, 2022

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 completing your first project at Ada! 🎉 I’ve added some suggestions & questions, let me know if there's anything I can clarify.

Comment on lines +121 to +123
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.

Great checks for all the movie data!

@@ -142,13 +144,14 @@ def test_moves_movie_from_watchlist_to_watched():
# Assert
assert len(updated_data["watchlist"]) == 1
assert len(updated_data["watched"]) == 2
assert updated_data["watched"][1]["title"] == "It Came from the Stack Trace"

Choose a reason for hiding this comment

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

The README isn't explicit about what order we should add movies to the list watched. If we want our tests to be independent from a specific implementation that adds movies to a particular location in the watched list, we could use the in keyword to check if the variable movie_to_watch is in the watched list instead of looking at a specific index. By checking for the whole dictionary, there's a side benefit that we don't need to check each key independently:

assert movie_to_watch in updated_data["watched"]

# Another option:
assert HORROR_1 in updated_data["watched"]

@@ -55,12 +90,12 @@ def test_friends_unique_movies_not_duplicated():
# Assert
assert len(friends_unique_movies) == 3

raise Exception("Test needs to be completed.")
#raise Exception("Test needs to be completed.")

Choose a reason for hiding this comment

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

We're missing adding new asserts for this test. What assertions could you make to ensure the exact movies that we expect are in the list friends_unique_movies?

Comment on lines 9 to 43
'''
#-----WAVE 3--------

USER_DATA_2 = {
"watched": [
FANTASY_1,
FANTASY_2,
FANTASY_3,
ACTION_1,
INTRIGUE_1,
INTRIGUE_2
],
}
USER_DATA_3 = copy.deepcopy(USER_DATA_2)

USER_DATA_3["friends"] = [
{
"watched": [
FANTASY_1,
FANTASY_3,
FANTASY_4,
HORROR_1,
]
},
{
"watched": [
FANTASY_1,
ACTION_1,
INTRIGUE_1,
INTRIGUE_3,
]
}
]

'''

Choose a reason for hiding this comment

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

It's all good to add commented out test data like this while we're actively working on tests, but we want to remove it before committing and pushing our changes to keep our test code concise and uncluttered.

Comment on lines +56 to +59
recommendations = get_new_rec_by_genre(sonyas_data)

# Assert
assert len(recommendations) == 0

Choose a reason for hiding this comment

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

Great act & assert steps!

#print(friends_movie_list)
my_unique_watched_list = []
for my_unique_movie in user_data["watched"]:
if my_unique_movie not in friends_movie_list and my_unique_movie not in my_unique_watched_list:

Choose a reason for hiding this comment

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

This line gets a bit long. We might want to drop it over a couple lines or create variables to hold the comparisons that we then use in an if statement:

is_movie_in_friends = my_unique_movie in friends_movie_list
is_movie_in_unique_list = my_unique_movie in my_unique_watched_list
if not is_movie_in_friends and not is_movie_in_unique_list:
    my_unique_watched_list.append(my_unique_movie)

return my_unique_watched_list
###+++++++++++++++++++++

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.

Nice implementation!


###### Wave 4++++++++++++++++++++++++++++
def get_available_recs(user_data):
friends_unique_watched_movies = 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.

Great code reuse!

Comment on lines +89 to +92
recommended_movies_for_me = []
for movie in friends_unique_watched_movies:
if movie["host"] in user_data["subscriptions"]:
recommended_movies_for_me.append(movie)

Choose a reason for hiding this comment

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

Nice algorithm! Another way we could approach filtering the unique_watched list is with a list comprehension:

# list comprehension
result = [movie for movie in friends_unique_watched_movies if movie["host"] in user_data["subscriptions"]]

This line is a bit long, in practice we would split a statement like this across lines, use some extra variables, or shorten some naming to keep under the PEP8 guide of 79 characters max per line:

# list comprehension
result = [movie for movie in friends_unique_watched_movies 
         if movie["host"] in user_data["subscriptions"]]

Comment on lines 108 to 111
friends_movie_list = []
for friend in user_data["friends"]:
for movie in friend["watched"]:
friends_movie_list.append(movie)

Choose a reason for hiding this comment

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

It looks like we duplicate some code that creates a list of our friends movies between get_unique_watched and this function. How could we use a helper function to remove the duplication?

@smchavan
Copy link
Author

smchavan commented Nov 11, 2022 via email

@kelsey-steven-ada
Copy link

Since the project is "Green" on the grading scale (the green/yellow/red grade is shared in Learn), you do not need to make any changes, but you are always welcome to if there is something you want to practice =]

@smchavan
Copy link
Author

smchavan commented Nov 11, 2022 via email

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