Skip to content

Charday Neal and Elzara Turakulova#3

Open
ielzara wants to merge 26 commits intoAda-C22:mainfrom
ielzara:main
Open

Charday Neal and Elzara Turakulova#3
ielzara wants to merge 26 commits intoAda-C22:mainfrom
ielzara:main

Conversation

@ielzara
Copy link
Copy Markdown

@ielzara ielzara commented Sep 25, 2024

No description provided.

Copy link
Copy Markdown

@apradoada apradoada left a comment

Choose a reason for hiding this comment

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

🟢 GREEN! 🟢

This project looks great, Elzara and Charday!

I left some comments but overall they are meant as suggestions for your future coding rather than things that are "wrong" or anything like that! I think the big thing to think about is that sometimes your code lost a little bit of consistency on how you handled data from function to function! Other than that, it's simply a matter of cleaning some things up and you're good! Just things to think about as you keep writing python!

# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************
assert updated_data["watched"] == [{
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 looks good! I love the way you set up this assertion! A small change is that it can be a little clunky to write out an entire list. You could remove the list aspect by removing the square brackets and adding that to the left side of the assertion:

 assert updated_data["watched"][0] == 

# *******************************************************************************************

@pytest.mark.skip()
assert updated_data["watched"] == [FANTASY_2, movie_to_watch]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same kind of idea as before, since this is a small list, I would simply check to see if the item at a specific index of the list is what you are looking for, rather than checking to make sure the entire list looks the same! One way we could make this a little more generic is to check and see that the item at index -1 is what we're looking for since we know it will always be appended to the end of the list!

# **************************************************************************************************

@pytest.mark.skip()
assert INTRIGUE_3 in friends_unique_movies
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 looks good too and I think it's a really good starting point for this particular test! One thing to think about however is what this test is actually testing! If we look at the name (test_friends_unique_movies_not_duplicated), it becomes clear that we will have the same movie in multiple friends watched lists! As a result, this test is looking specifically to see how many times that movie gets added. While checking to see if it's in the list you create works, are there other ways to make sure it isn't duplicated?

}

result = get_new_rec_by_genre(sonyas_data)
assert result == []
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 looks good!

if not title or not genre or not rating:
return None

return {"title": title, "genre": genre, "rating": rating}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The way y'all set up this function is really great. I love the guard clause/normal flow structure that you have set up here!

Comment on lines +117 to +123
for friend in user_data["friends"]:
for movie in friend["watched"]:
title = movie["title"]
if title not in user_movie_titles:
if title not in friends_movie_titles:
friends_movie_titles.add(title)
unique_friends_movies.append(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.

The one small thing to think about here is how the not in statement works. It's going to have to loop through the collections to see if the specified titles exist within them. As a result, we end up with a potential for 4 nested loops here. I wonder if there is a way this could be refactored! Also, if we think about how the friends_movie_titles set works, we don't actually need to check and see if a title exists within it at all! If it's a set, we can just add it and any duplicates just won't make the cut!

def get_available_recs(user_data):

# Get unique movies friends watched, but user hasn't
unique_movies = 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 job using your function from a previous wave! Helper functions are always great!

# Append a movie to a list of recommended movies
# if a movie is hosted by a subscription user has acces to
for movie in unique_movies:
host = movie["host"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm just calling this out because it ends up being a little inconsistent from function to function. Sometimes you store data from the dictionary in a new variable, other times you don't. As you get more comfortable with programming, I would lean toward directly accessing the data, but more importantly, keep things consistent across your program!


# Create list of recommended movies with most frequent genre
not_watched = get_friends_unique_watched(user_data)
recommended_movies = [
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Y'all killed it with these list comprehensions!

if movie["title"] in favorite_movies
]

return recommended_favorites
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 function looks really great too! Good job using methods from before and as always, another good list comprehension!

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.

3 participants