From 59e4492725cf7d8b8d1b2e37d02543c798fa2afc Mon Sep 17 00:00:00 2001 From: Janice Date: Mon, 27 Mar 2023 11:36:37 -0700 Subject: [PATCH 01/21] added pair plan to README file --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index ba28bf2ab..60917d910 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +Pair Plan: +- Access needs + -Tuesday and Thursday cowoorking 1-3 + - after class if needed + - work from home if needed -starting 7pm ~ 2 hours + +-your learning style + - hands on practice +-how you prefer to receive feedback + - through slack or in person +-team communication skill to improve on with this experience + - tell each other of changes we make on our own (like refactoring) + + # Viewing Party ## Skills Assessed From caa1837e05ed838937086342d044b8300cf8db78 Mon Sep 17 00:00:00 2001 From: Janice Date: Mon, 27 Mar 2023 11:59:32 -0700 Subject: [PATCH 02/21] completed create_movie function --- viewing_party/party.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..acc3e49f9 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,8 +1,15 @@ # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): - pass + new_movie = {} + if not title or not genre or not rating: + return None + else: + new_movie['title'] = title + new_movie['genre'] = genre + new_movie['rating'] = rating + return new_movie # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From 7f98a243d2fc0e803d3c7be860e6fb1f3bdb1e0e Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Tue, 28 Mar 2023 13:16:03 -0700 Subject: [PATCH 03/21] completed add_to_watched function --- viewing_party/party.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index acc3e49f9..201ee692f 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -10,6 +10,12 @@ def create_movie(title, genre, rating): new_movie['genre'] = genre new_movie['rating'] = rating return new_movie + +def add_to_watched(user_data, movie): + for data in user_data: + user_data["watched"].append(movie) + + return user_data # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From d62602bf5767027ab92b6a30592bb1a1696efe0a Mon Sep 17 00:00:00 2001 From: Janice Date: Tue, 28 Mar 2023 13:21:01 -0700 Subject: [PATCH 04/21] completed add to watchlist --- viewing_party/party.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 201ee692f..bee2d22a1 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -16,6 +16,12 @@ def add_to_watched(user_data, movie): user_data["watched"].append(movie) return user_data + +def add_to_watchlist(user_data, movie): + for data in user_data: + user_data["watchlist"].append(movie) + return user_data + # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From b2a298438353c21ceeb1a05d7148ac5f3a0b1cd8 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Tue, 28 Mar 2023 13:58:12 -0700 Subject: [PATCH 05/21] completed test moves_movie_from_watchlist_to_empty_watched --- tests/test_wave_01.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 669efee6a..0bfaa0ead 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -4,7 +4,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_create_successful_movie(): # Arrange movie_title = MOVIE_TITLE_1 @@ -19,7 +19,7 @@ def test_create_successful_movie(): assert new_movie["genre"] == GENRE_1 assert new_movie["rating"] == pytest.approx(RATING_1) -@pytest.mark.skip() +# @pytest.mark.skip() def test_create_no_title_movie(): # Arrange movie_title = None @@ -32,7 +32,7 @@ def test_create_no_title_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() def test_create_no_genre_movie(): # Arrange movie_title = "Title A" @@ -45,7 +45,7 @@ def test_create_no_genre_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() def test_create_no_rating_movie(): # Arrange movie_title = "Title A" @@ -58,7 +58,7 @@ def test_create_no_rating_movie(): # Assert assert new_movie is None -@pytest.mark.skip() +# @pytest.mark.skip() def test_adds_movie_to_user_watched(): # Arrange movie = { @@ -79,7 +79,7 @@ def test_adds_movie_to_user_watched(): assert updated_data["watched"][0]["genre"] == GENRE_1 assert updated_data["watched"][0]["rating"] == RATING_1 -@pytest.mark.skip() +# @pytest.mark.skip() def test_adds_movie_to_non_empty_user_watched(): # Arrange movie = { @@ -99,7 +99,7 @@ def test_adds_movie_to_non_empty_user_watched(): assert movie in updated_data["watched"] assert FANTASY_2 in updated_data["watched"] -@pytest.mark.skip() +# @pytest.mark.skip() def test_adds_movie_to_user_watchlist(): # Arrange movie = { @@ -120,7 +120,7 @@ def test_adds_movie_to_user_watchlist(): assert updated_data["watchlist"][0]["genre"] == GENRE_1 assert updated_data["watchlist"][0]["rating"] == RATING_1 -@pytest.mark.skip() +# @pytest.mark.skip() def test_adds_movie_to_non_empty_user_watchlist(): # Arrange movie = { @@ -140,7 +140,7 @@ def test_adds_movie_to_non_empty_user_watchlist(): assert movie in updated_data["watchlist"] assert FANTASY_2 in updated_data["watchlist"] -@pytest.mark.skip() +# @pytest.mark.skip() def test_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -158,13 +158,14 @@ def test_moves_movie_from_watchlist_to_empty_watched(): # Assert assert len(updated_data["watchlist"]) == 0 assert len(updated_data["watched"]) == 1 + assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() def test_moves_movie_from_watchlist_to_watched(): # Arrange movie_to_watch = HORROR_1 @@ -188,7 +189,7 @@ def test_moves_movie_from_watchlist_to_watched(): # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() +# @pytest.mark.skip() def test_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 From 05b77275315ecd624c0b42895d3fbd71d32435a4 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Tue, 28 Mar 2023 14:06:03 -0700 Subject: [PATCH 06/21] completed test moves_movie_from_watchlist_to_watched --- tests/test_wave_01.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 0bfaa0ead..64cfb051f 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -183,8 +183,9 @@ 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] == movie_to_watch - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* From f4ce16cab931a99eb538e438f010ffb2866a9fc5 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Tue, 28 Mar 2023 14:08:18 -0700 Subject: [PATCH 07/21] completed watch_movie --- viewing_party/party.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index bee2d22a1..51e3b579d 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -22,6 +22,13 @@ def add_to_watchlist(user_data, movie): user_data["watchlist"].append(movie) return user_data +def watch_movie(user_data, title): + for user in user_data["watchlist"]: + if user["title"] == title: + user_data["watchlist"].remove(user) + user_data["watched"].append(user) + + return user_data # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From dbff1f53d0430ce0b69b6e6635d6498f4cb6f265 Mon Sep 17 00:00:00 2001 From: Janice Date: Tue, 28 Mar 2023 14:16:35 -0700 Subject: [PATCH 08/21] completed get_watched_avg_rating --- viewing_party/party.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 51e3b579d..e8ae80f83 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -33,6 +33,17 @@ def watch_movie(user_data, title): # ------------- WAVE 2 -------------------- # ----------------------------------------- +def get_watched_avg_rating(user_data): + sum = 0 + counter = 0 + if not user_data['watched']: + return 0.0 + for movies in user_data['watched']: + sum += movies['rating'] + counter +=1 + + return sum/counter + # ----------------------------------------- # ------------- WAVE 3 -------------------- From a253f04a81aebe21192ee7d5fbcce4f46a60a9ee Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Tue, 28 Mar 2023 14:31:11 -0700 Subject: [PATCH 09/21] completed get_most_watched_genre --- tests/test_wave_02.py | 10 +++++----- viewing_party/party.py | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 19f045c79..64b62729d 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_calculates_watched_average_rating(): # Arrange janes_data = clean_wave_2_data() @@ -14,7 +14,7 @@ def test_calculates_watched_average_rating(): assert average == pytest.approx(3.58333) assert janes_data == clean_wave_2_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_empty_watched_average_rating_is_zero(): # Arrange janes_data = { @@ -27,7 +27,7 @@ def test_empty_watched_average_rating_is_zero(): # Assert assert average == pytest.approx(0.0) -@pytest.mark.skip() +# @pytest.mark.skip() def test_most_watched_genre(): # Arrange janes_data = clean_wave_2_data() @@ -39,7 +39,7 @@ def test_most_watched_genre(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_most_watched_genre_order_mixed(): # Arrange janes_data = clean_wave_2b_data() @@ -51,7 +51,7 @@ def test_most_watched_genre_order_mixed(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2b_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_genre_is_None_if_empty_watched(): # Arrange janes_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index e8ae80f83..bb73e2f42 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -44,6 +44,27 @@ def get_watched_avg_rating(user_data): return sum/counter +def get_most_watched_genre(user_data): + if not user_data["watched"]: + return None + + genre_dict = {} + for movies in user_data["watched"]: + if movies["genre"] not in genre_dict: + genre_dict[movies["genre"]] = 1 + else: + genre_dict[movies["genre"]] += 1 + + largest_value = 0 + most_common_genre = "" + for genre, freq in genre_dict.items(): + if freq > largest_value: + largest_value = freq + most_common_genre = genre + + return most_common_genre + + # ----------------------------------------- # ------------- WAVE 3 -------------------- From 5708563aacfd58184a9ea27fb3488add8aadafb8 Mon Sep 17 00:00:00 2001 From: Janice Date: Wed, 29 Mar 2023 15:08:39 -0700 Subject: [PATCH 10/21] completed get unique watched function --- viewing_party/party.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index bb73e2f42..481b1d4d3 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,4 +1,5 @@ -# ------------- WAVE 1 -------------------- +# +# ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): new_movie = {} @@ -70,7 +71,18 @@ def get_most_watched_genre(user_data): # ------------- WAVE 3 -------------------- # ----------------------------------------- - +def get_unique_watched(user_data): + unique_movies = [] + friend_movies = [] + + for watched_list in user_data["friends"]: + for movies in watched_list["watched"]: + friend_movies.append(movies) + for user_movies in user_data["watched"]: + if user_movies not in friend_movies: + unique_movies.append(user_movies) + + return unique_movies # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- From f27b75436117281f986b99db4b30fa24aeab615c Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Wed, 29 Mar 2023 15:37:32 -0700 Subject: [PATCH 11/21] completed test_wave_03 --- tests/test_wave_03.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 046429360..a168f0cc0 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +# @pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -16,7 +16,7 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_my_not_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -28,7 +28,7 @@ def test_my_not_unique_movies(): # Assert assert len(amandas_unique_movies) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -43,7 +43,7 @@ def test_friends_unique_movies(): assert FANTASY_4 in friends_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_unique_movies_not_duplicated(): # Arrange amandas_data = clean_wave_3_data() @@ -54,13 +54,14 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 + assert friends_unique_movies.count(INTRIGUE_3) == 1 - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** -@pytest.mark.skip() +# @pytest.mark.skip() def test_friends_not_unique_movies(): # Arrange amandas_data = { From 1d86465937d8873799888e226f7a9b79d77c418f Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Wed, 29 Mar 2023 15:38:17 -0700 Subject: [PATCH 12/21] completed get_friends_unique_watched function --- viewing_party/party.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 481b1d4d3..08906dd7c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -83,6 +83,22 @@ def get_unique_watched(user_data): unique_movies.append(user_movies) return unique_movies + +def get_friends_unique_watched(user_data): + unique_movies = [] + user_movies = [] + + for movies in user_data["watched"]: + user_movies.append(movies) + + for watched_list in user_data["friends"]: + for movies in watched_list["watched"]: + if movies not in user_movies and movies not in unique_movies: + unique_movies.append(movies) + + print(unique_movies) + + return unique_movies # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- From 88c7daee4b76d63c55341d316aba1bc05edd7a53 Mon Sep 17 00:00:00 2001 From: Janice Date: Wed, 29 Mar 2023 15:57:20 -0700 Subject: [PATCH 13/21] completed get available recs function --- viewing_party/party.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 08906dd7c..3ef134145 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -103,6 +103,17 @@ def get_friends_unique_watched(user_data): # ------------- WAVE 4 -------------------- # ----------------------------------------- +def get_available_recs(user_data): + recommended = [] + unique_movies = get_friends_unique_watched(user_data) + + for subscription in user_data["subscriptions"]: + for movies in unique_movies: + if subscription == movies["host"]: + recommended.append(movies) + return recommended + + # ----------------------------------------- # ------------- WAVE 5 -------------------- # ----------------------------------------- From dc26f66231aca8300bca8cfa11a0ad774b84b160 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 13:15:02 -0700 Subject: [PATCH 14/21] completed get_new_rec_by_genre --- viewing_party/party.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/viewing_party/party.py b/viewing_party/party.py index 3ef134145..5caf1a599 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -118,3 +118,13 @@ def get_available_recs(user_data): # ------------- WAVE 5 -------------------- # ----------------------------------------- +def get_new_rec_by_genre(user_data): + recommended_by_genre = [] + unique_movies = get_friends_unique_watched(user_data) + most_common_genre = get_most_watched_genre(user_data) + + for unique_movie in unique_movies: + if unique_movie["genre"] == most_common_genre: + recommended_by_genre.append(unique_movie) + + return recommended_by_genre \ No newline at end of file From a1218e2a3f8fbf7a37f50a3c2f02d65ceb13df67 Mon Sep 17 00:00:00 2001 From: Janice Date: Thu, 30 Mar 2023 13:22:41 -0700 Subject: [PATCH 15/21] completed test test new genre rec from empty friends --- tests/test_wave_05.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index b2ba9ad33..0f134ca8c 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -38,7 +38,7 @@ def test_new_genre_rec_from_empty_watched(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() +# @pytest.mark.skip() def test_new_genre_rec_from_empty_friends(): # Arrange sonyas_data = { @@ -52,12 +52,17 @@ def test_new_genre_rec_from_empty_friends(): } ] } + # Act + recommendations = get_new_rec_by_genre(sonyas_data) - raise Exception("Test needs to be completed.") + #Assert + assert len(recommendations) == 0 + # raise Exception("Test needs to be completed.") # ********************************************************************* # ****** Complete the Act and Assert Portions of these tests ********** # ********************************************************************* - + + @pytest.mark.skip() def test_unique_rec_from_favorites(): # Arrange From 062e37b3ca53adc64653cdc3a34c5755cf4e925f Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 13:31:03 -0700 Subject: [PATCH 16/21] completed get_rec_from_favorites --- viewing_party/party.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 5caf1a599..aac33e484 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -127,4 +127,18 @@ def get_new_rec_by_genre(user_data): if unique_movie["genre"] == most_common_genre: recommended_by_genre.append(unique_movie) - return recommended_by_genre \ No newline at end of file + return recommended_by_genre + +def get_rec_from_favorites(user_data): + friend_movies = [] + recommendations = [] + + for watched_list in user_data["friends"]: + for movies in watched_list["watched"]: + friend_movies.append(movies) + + for favorites in user_data["favorites"]: + if favorites not in friend_movies: + recommendations.append(favorites) + + return recommendations From ff248439152d5afcb658c9abffe599e97aa3732b Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 13:54:06 -0700 Subject: [PATCH 17/21] refactored functions in Wave 1 --- viewing_party/party.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index aac33e484..fad2307f2 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -3,31 +3,29 @@ def create_movie(title, genre, rating): new_movie = {} + if not title or not genre or not rating: return None - else: new_movie['title'] = title new_movie['genre'] = genre new_movie['rating'] = rating + return new_movie def add_to_watched(user_data, movie): - for data in user_data: - user_data["watched"].append(movie) - + user_data["watched"].append(movie) return user_data def add_to_watchlist(user_data, movie): - for data in user_data: - user_data["watchlist"].append(movie) + user_data["watchlist"].append(movie) return user_data def watch_movie(user_data, title): - for user in user_data["watchlist"]: - if user["title"] == title: - user_data["watchlist"].remove(user) - user_data["watched"].append(user) + for movie in user_data["watchlist"]: + if movie["title"] == title: + user_data["watchlist"].remove(movie) + user_data["watched"].append(movie) return user_data # ----------------------------------------- From 18bbd38ede84948e71f4d25cbbd79b4c45962efb Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 13:59:36 -0700 Subject: [PATCH 18/21] refactored functions in Wave 2 --- viewing_party/party.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index fad2307f2..218c7c541 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -35,27 +35,30 @@ def watch_movie(user_data, title): def get_watched_avg_rating(user_data): sum = 0 counter = 0 + if not user_data['watched']: return 0.0 + for movies in user_data['watched']: sum += movies['rating'] - counter +=1 + counter += 1 return sum/counter def get_most_watched_genre(user_data): + genre_dict = {} + largest_value = 0 + most_common_genre = "" + if not user_data["watched"]: return None - genre_dict = {} for movies in user_data["watched"]: if movies["genre"] not in genre_dict: genre_dict[movies["genre"]] = 1 else: genre_dict[movies["genre"]] += 1 - largest_value = 0 - most_common_genre = "" for genre, freq in genre_dict.items(): if freq > largest_value: largest_value = freq From e49f5a6ea2521ee603f83b7780ece9304d00a9c0 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 14:10:20 -0700 Subject: [PATCH 19/21] refactored Wave 3 functions --- viewing_party/party.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 218c7c541..e03a330aa 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -79,6 +79,7 @@ def get_unique_watched(user_data): for watched_list in user_data["friends"]: for movies in watched_list["watched"]: friend_movies.append(movies) + for user_movies in user_data["watched"]: if user_movies not in friend_movies: unique_movies.append(user_movies) @@ -96,8 +97,6 @@ def get_friends_unique_watched(user_data): for movies in watched_list["watched"]: if movies not in user_movies and movies not in unique_movies: unique_movies.append(movies) - - print(unique_movies) return unique_movies # ----------------------------------------- From a7fde5a629ddda93cd87b9f067f0a4b499364ae5 Mon Sep 17 00:00:00 2001 From: Sophia Tran Date: Thu, 30 Mar 2023 14:35:04 -0700 Subject: [PATCH 20/21] Added comments to code --- viewing_party/party.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index e03a330aa..0f39f5dd0 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -4,6 +4,7 @@ def create_movie(title, genre, rating): new_movie = {} +# Check to see if there is a title, genre, rating if not title or not genre or not rating: return None else: @@ -14,14 +15,17 @@ def create_movie(title, genre, rating): return new_movie def add_to_watched(user_data, movie): +# Add movie to user's watched list user_data["watched"].append(movie) return user_data def add_to_watchlist(user_data, movie): +# Add movie to user's watchlist list user_data["watchlist"].append(movie) return user_data def watch_movie(user_data, title): +# Check to see if movie's in watchlist, and put into watched for movie in user_data["watchlist"]: if movie["title"] == title: user_data["watchlist"].remove(movie) @@ -53,12 +57,14 @@ def get_most_watched_genre(user_data): if not user_data["watched"]: return None +# Count frequency of genre for movies in user_data["watched"]: if movies["genre"] not in genre_dict: genre_dict[movies["genre"]] = 1 else: genre_dict[movies["genre"]] += 1 +# Find the most common genre for genre, freq in genre_dict.items(): if freq > largest_value: largest_value = freq @@ -76,10 +82,13 @@ def get_unique_watched(user_data): unique_movies = [] friend_movies = [] +# Create a list of movies that friends have for watched_list in user_data["friends"]: for movies in watched_list["watched"]: friend_movies.append(movies) +# Check to see if there are common movies between user movies and friends movies +# Adds uncommon movies for user for user_movies in user_data["watched"]: if user_movies not in friend_movies: unique_movies.append(user_movies) @@ -90,9 +99,12 @@ def get_friends_unique_watched(user_data): unique_movies = [] user_movies = [] +# Create a list of movies that users have for movies in user_data["watched"]: user_movies.append(movies) +# Check to see if there are common movies between user movies and friends movies +# Adds uncommon movies for friends for watched_list in user_data["friends"]: for movies in watched_list["watched"]: if movies not in user_movies and movies not in unique_movies: @@ -107,6 +119,7 @@ def get_available_recs(user_data): recommended = [] unique_movies = get_friends_unique_watched(user_data) +# Recommend movies with matching host and subscription for subscription in user_data["subscriptions"]: for movies in unique_movies: if subscription == movies["host"]: @@ -123,9 +136,10 @@ def get_new_rec_by_genre(user_data): unique_movies = get_friends_unique_watched(user_data) most_common_genre = get_most_watched_genre(user_data) - for unique_movie in unique_movies: - if unique_movie["genre"] == most_common_genre: - recommended_by_genre.append(unique_movie) +# Recommends movies from friends unique list based on most common genre + for movie in unique_movies: + if movie["genre"] == most_common_genre: + recommended_by_genre.append(movie) return recommended_by_genre @@ -133,10 +147,12 @@ def get_rec_from_favorites(user_data): friend_movies = [] recommendations = [] +# Create list of friends movies for watched_list in user_data["friends"]: for movies in watched_list["watched"]: friend_movies.append(movies) +# Recommend movies in user favorites but not in friends movies for favorites in user_data["favorites"]: if favorites not in friend_movies: recommendations.append(favorites) From 4471126f44807fa64745da14319a3a8747744573 Mon Sep 17 00:00:00 2001 From: Janice Date: Thu, 30 Mar 2023 16:02:48 -0700 Subject: [PATCH 21/21] refactored code --- viewing_party/party.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 0f39f5dd0..86e13fda2 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -8,9 +8,9 @@ def create_movie(title, genre, rating): if not title or not genre or not rating: return None else: - new_movie['title'] = title - new_movie['genre'] = genre - new_movie['rating'] = rating + new_movie["title"] = title + new_movie["genre"] = genre + new_movie["rating"] = rating return new_movie @@ -40,11 +40,11 @@ def get_watched_avg_rating(user_data): sum = 0 counter = 0 - if not user_data['watched']: + if not user_data["watched"]: return 0.0 - for movies in user_data['watched']: - sum += movies['rating'] + for movies in user_data["watched"]: + sum += movies["rating"] counter += 1 return sum/counter