Skip to content

C22, sphinx, Priyanka and Maybellene - #4

Open
mayboolean wants to merge 17 commits into
Ada-C22:mainfrom
mayboolean:main
Open

C22, sphinx, Priyanka and Maybellene#4
mayboolean wants to merge 17 commits into
Ada-C22:mainfrom
mayboolean:main

Conversation

@mayboolean

Copy link
Copy Markdown

No description provided.

Comment thread viewing_party/party.py Outdated
watched_list = user_data["watched"]
total_rating = 0

if watched_list == []:

@PriyankaKaramchandani PriyankaKaramchandani Sep 26, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi Ashley,
Sorry about repeating this issue on line 91 and 113
The more Pythonic way would be:
if not lod_watched
Versus what I have here. I hadn't read your feedback when I wrote this

@yangashley yangashley left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work on viewing-party, Priyanka and Maybellene!

I also see that you two made frequent commits, nice job!

Let me know if you have any questions about my review comments.

Comment thread tests/test_wave_01.py
# Act
new_movie = create_movie(movie_title, genre, rating)

print(new_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.

Remove debugging print statements before committing code for review

Comment thread tests/test_wave_01.py
Comment on lines +165 to +169
assert updated_data["watched"] == [{
"title": MOVIE_TITLE_1,
"genre": GENRE_1,
"rating": RATING_1
}]

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 tests/test_wave_01.py
Comment on lines +193 to +194
assert updated_data["watchlist"] == [FANTASY_1]
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.

Instead of putting FANTASY_1 in a list and checking that it's equal to updated_data["watchlist"], we could write the assertion on line 193 like:

assert FANTASY_1 in updated_data["watchlist"] 

How could you write line 194 using the in operator? Also, if the order of the movies in updated_data["watched"] was movie_to_watch and then FANTASY_2, this test would fail. Since we're not concerned with order, using in is a sufficient check.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

would it be:
assert FANTASY2 in updated_data[watched] and movie_to_watch in updated_data[watched]

or
assert for movie in [FANTASY_2, movie_to_watch] if movie in updated_data["watched"]

@yangashley yangashley Oct 2, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah more like your first assertion, but I would break em up on two lines instead of using the and for readability.

assert FANTASY_2 in updated_data["watched"] 
assert movie_to_watch in updated_data["watched"] 

Comment thread tests/test_wave_03.py
amandas_data = clean_wave_3_data()
amandas_data["friends"][0]["watched"].append(INTRIGUE_3)

expected_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.

expected_movies is created and then isn't accessed in the test so we should remove it from it to keep the test concise.

Comment thread tests/test_wave_03.py

# Assert
assert len(friends_unique_movies) == 3
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.

You check that INTRIGUE_3 is in friends_unique_movies. How about explicitly checking that the other two movies that are a part of the movies only watched by friends are also in friends_unique_movies?

Comment thread viewing_party/party.py
Comment on lines +143 to +147
titles_friends_watched = set()

for friend_movie_dict in user_data["friends"]:
for movie in friend_movie_dict["watched"]:
titles_friends_watched.add(movie["title"])

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 currently has 2 responsibilities: getting all the movies friends have watched and then finding unique movies. Prefer this logic to be pulled into a helper function so that it can be called here.

Comment thread viewing_party/party.py
Comment on lines +167 to +169
list_titles_watched = set()
for movie in user_data["watched"]:
list_titles_watched.add(movie["title"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this function, you build up a list of all the movies a user has watched and then you iterate through all the movies a user's friends have watched to create list_friends_unique_movie.

What if you flipped the logic so that you first get all the movies the friends have watched (like you did in get_unique_watched) and then you can check that the friends' movies list are not in the user's movies list?

If you invert the logic, then you could use reuse the hypothetical helper function that gets friends' movies here too and keep this logic to a single responsibility.

Like this:

def get_friends_unique_watched(user_data):
    friends_watched_movies = get_friends_movies()

    list_friends_unique_movie = []

    for movie in friends_watched_movies:
         if movie not in user_data["watched"] and movie not in list_friends_unique_movie:
                list_friends_unique_movie.append(movie)

    return list_friends_unique_movie

Comment thread viewing_party/party.py
}
'''

lod_unique_friends_movie = 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.

Nice job invoking a method you already called to keep your code DRY

Comment thread viewing_party/party.py
Comment on lines +211 to +214
lod_unique_friends_movie = get_friends_unique_watched(user_data)

# get user's most freq genre
user_freq_genre = get_most_watched_genre(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
"friends": [ {"watched": [...{},{}...] }, {"watched": [...{},{}...] }]
}
'''
# list of movies only the user has seen (not any of the friends)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since you're using docstrings throughout the project, I'd prefer this function's docstring to have more details about what the function returns instead of having this detail as an inline comment in the function.

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