Conversation
jericahuang
left a comment
There was a problem hiding this comment.
Excellent first project, Hang! This project is green. 🟢
You implemented most functions according to the specification and had good code style throughout. Great use of helper functions and parsing nested data structures. Nice job finishing out the tests as well. I would recommend making more frequent commits as you progress through the milestones.
Yes, list comprehensions definitely can condense the number of lines of code, though they effectively do the same as a for loop-conditional-append structure. For some of the "get unique ..." functions, a set data type could've been used because of its helpful property of containing all unique values. It can be easily converted to a list to meet the function's return type expectation. I think your implementations were good as they are!
See my line-by-line comments for more detail. Keep up the great work!
| assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 | ||
| assert updated_data["watched"][0] == { | ||
| "title": MOVIE_TITLE_1, | ||
| "genre": GENRE_1, |
There was a problem hiding this comment.
👍🏻 Great assert statements! Love that you used all the constants provided. Makes it a very thorough test.
| assert updated_data["watched"][0]["title"] == "The Lord of the Functions: The Two Parameters" | ||
| assert updated_data["watched"][1]["title"] == "It Came from the Stack Trace" |
|
|
||
| # Act | ||
| average = get_watched_avg_rating(janes_data) | ||
| print(average) |
There was a problem hiding this comment.
Would advise to omit or comment out print statements in your final submission! In large projects, the console is great for debugging but when it's used in production or by other developers who are unfamiliar with your code, an excess of printing can clutter and confuse them as they look at the console raising questions like “What does this mean, why is it printed, where is this coming from?”
| assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 | ||
| assert updated_data["watched"][0] == { | ||
| "title": MOVIE_TITLE_1, | ||
| "genre": GENRE_1, | ||
| "rating": RATING_1 } |
There was a problem hiding this comment.
👍🏻 Great assert statements! Love that you used all the constants provided by testing the whole dictionary value. Makes it a very thorough test.
| # ************************************************************************************************** | ||
|
|
||
| @pytest.mark.skip() | ||
| assert INTRIGUE_3 in friends_unique_movies |
| friends_watched_titles = [] | ||
| for friend in user_data["friends"]: | ||
| for movie in friend["watched"]: | ||
| if movie["title"] not in friends_watched_titles: | ||
| friends_watched_titles.append(movie["title"]) | ||
|
|
||
|
|
||
|
|
||
| # ----------------------------------------- | ||
| # ------------- WAVE 4 -------------------- | ||
| # ----------------------------------------- | ||
| unique_movies = [] | ||
| for user_watched_movie in user_data["watched"]: | ||
| if user_watched_movie["title"] not in friends_watched_titles: |
There was a problem hiding this comment.
Great logic and parsing through this nested data structure.
| if movie not in user_list: | ||
| friend_unique_movies.append(movie) | ||
| #removing duplicates | ||
| friend_unique_no_duplicate = [i for n, i in enumerate(friend_unique_movies) |
There was a problem hiding this comment.
Interesting application of enumerate! Would recommend variable names that are more descriptive so one would more easily know what is represented by i and n.
|
|
||
| for friend in user_data["friends"]: | ||
| for movie in friend["watched"]: | ||
| if movie["host"] in user_data["subscriptions"] and movie not in user_data["watched"]: |
| # we have to make a list of recommended movies from the friend's unique watched list IF it is in the most frequently watched genre | ||
|
|
||
| recommended_movies = [] | ||
| most_watched_genre = get_most_watched_genre(user_data) |
There was a problem hiding this comment.
Yes! This helper function is very handy here.
| # make a list of recommendations from user's favorite | ||
|
|
||
| recommendations =[] | ||
| user_watched_movies = get_unique_watched(user_data) |
There was a problem hiding this comment.
Again, great use of a helper function!
This project was challenging, but I learned a lot through trial and error. Aside from list comprehensions, what other ways can I condense my code or make it more readable. Were there any methods I could have used instead? Should I include more comments about what some of lines are doing, and should I exclude some of my pseudocode type comments.