From b664d2d24d3bc7dcae89b5c09b2fb6e96ffd63e2 Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Sun, 18 Sep 2022 17:32:18 -0400 Subject: [PATCH 01/10] wave_1_passed_3_of_first_4_tests --- tests/test_wave_01.py | 8 ++++---- viewing_party/party.py | 13 ++++++++++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 6be6994a5..c5222ca11 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -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 = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..46b657c00 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,7 +1,18 @@ # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): - pass + if title or genre ==None: + return None + elif rating== None: + return None + else: + new_movie = {'title': title, 'genre': genre, 'rating': rating} + # print(type(new_movie)) + # print(new_movie) + return new_movie + +def add_to_watched(user_data, movie): + # ----------------------------------------- # ------------- WAVE 2 -------------------- From deadbb3ec9915fc35041ee3b54c4015a5a1f83fd Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Mon, 19 Sep 2022 17:10:54 -0400 Subject: [PATCH 02/10] passed_wave_1 --- tests/test_wave_01.py | 21 ++++++++-------- viewing_party/party.py | 55 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index c5222ca11..03af0cb44 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -15,11 +15,11 @@ def test_create_successful_movie(): new_movie = create_movie(movie_title, genre, rating) # Assert - assert new_movie["title"] == MOVIE_TITLE_1 - assert new_movie["genre"] == GENRE_1 - assert new_movie["rating"] == pytest.approx(RATING_1) + assert new_movie["title"] == movie_title + assert new_movie["genre"] == genre + assert new_movie["rating"] == pytest.approx(rating) -pytest.mark.skip() +#pytest.mark.skip() def test_create_no_title_movie(): # Arrange movie_title = None @@ -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 = { @@ -100,7 +100,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_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -142,13 +142,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"] ==[{'title': 'The Lord of the Functions: The Two Parameters', 'genre': 'Fantasy', 'rating': 4.0}, {'title': 'It Came from the Stack Trace', 'genre': 'Horror', 'rating': 3.5}] - 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_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 @@ -163,5 +164,5 @@ def test_does_nothing_if_movie_not_in_watchlist(): # Assert assert len(updated_data["watchlist"]) == 1 assert len(updated_data["watched"]) == 1 - assert movie_to_watch not in updated_data["watchlist"] - assert movie_to_watch not in updated_data["watched"] + assert updated_data['watchlist']==[{'title': 'The Lord of the Functions: The Fellowship of the Function', 'genre': 'Fantasy', 'rating': 4.8}] + assert updated_data['watched']==[{'title': 'The Lord of the Functions: The Two Parameters', 'genre': 'Fantasy', 'rating': 4.0}] \ No newline at end of file diff --git a/viewing_party/party.py b/viewing_party/party.py index 46b657c00..0c8ba0f7c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,18 +1,65 @@ # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): - if title or genre ==None: + if title ==None: + return None + elif genre ==None: return None elif rating== None: return None else: + new_movie = {'title': title, 'genre': genre, 'rating': rating} - # print(type(new_movie)) - # print(new_movie) return new_movie + def add_to_watched(user_data, movie): - + + #begin list of watched movies + updated_data=user_data.copy() + watch_list=[] + + #add new movie to list + watch_list.append(movie) + print(watch_list) + + #add list to dictionary + updated_data['watched']=watch_list + + #OUTPUT IS dictionary of list. Key is 'Watched" value is list of movies [index, movie] + return updated_data + +def add_to_watchlist(user_data, movie): +#this function creates list of movies based on boolean condition== "watched" or !="watched" + #begin list of watched movies + + updated_data=user_data.copy() + + watch_list=[] + #add new movie to list + watch_list.append(movie) + print(watch_list) + #add list to dictionary + + updated_data['watchlist']=watch_list + print(updated_data) + #OUTPUT IS dictionary of list. Key is 'Watched" value is list of movies [index, movie] + return updated_data + +def watch_movie(user_data, title): + for movie in user_data["watchlist"]: + #removed assert statements below -- modified test to return original value for user_data + #assert movie_to_watch not in updated_data["watchlist"] + #assert movie_to_watch not in updated_data["watched"] + if movie["title"] == title: + user_data["watched"].append(movie) + user_data["watchlist"].remove(movie) + return user_data + + + + + # ----------------------------------------- # ------------- WAVE 2 -------------------- From 8b3d0a30ed4344b3d28f3cb576e4be7db2fe728a Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Mon, 19 Sep 2022 21:21:28 -0400 Subject: [PATCH 03/10] passed_wave_2 --- tests/test_wave_01.py | 13 ++++++---- tests/test_wave_02.py | 8 +++--- viewing_party/party.py | 58 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 66 insertions(+), 13 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 03af0cb44..8d0f2ee03 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 @@ -118,13 +118,16 @@ 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']==[{'title': 'It Came from the Stack Trace', 'genre': 'Horror', 'rating': 3.5}] + + + - 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 @@ -149,7 +152,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 diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 3a588299e..4a9749c89 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_genre_is_None_if_empty_watched(): # Arrange janes_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 0c8ba0f7c..b7e9e7be2 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -58,13 +58,63 @@ def watch_movie(user_data, title): - - - # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- - +def get_watched_avg_rating(user_data): + #user_data is dictionary with a 'watched' list of movie + #user_data[watched][list_of_watched_movies] + #list_of_watched_movies[index][movie.dict] + sum=0 + total_movies_in_list=0 + if len(user_data['watched'])==0: + return sum + else: + for movie in user_data["watched"]: + sum+=movie['rating'] + total_movies_in_list+=1 + return sum/total_movies_in_list + +def get_most_watched_genre(user_data): + + # if len(user_data['watched'])==0: + # return None + + # else: + fantasy_count=0 + action_count=0 + intrigue_count=0 + horror_count=0 + genre_dict=dict() + #print (type(genre_list)) + + for movie in user_data["watched"]: + if movie['genre']=='Fantasy': + fantasy_count+=1 + genre_dict['Fantasy']= fantasy_count + elif movie['genre']=='Action': + #genre_list[action_count]+=1 + action_count+=1 + genre_dict['Action']=action_count + elif movie['genre']=='Intrigue': + #genre_list[intrigue_count]+=1 + intrigue_count+=1 + genre_dict['Intrigue']=intrigue_count + elif movie['genre']=='Horror': + #genre_list[horror_count]+=1 + horror_count+=1 + genre_dict['Horror']= horror_count + + #max_count=max(genre_dict.values()) + if len(genre_dict)==0: + return None + else: + popular_genre=max(genre_dict, key=genre_dict.get) + return popular_genre + + + + # ----------------------------------------- # ------------- WAVE 3 -------------------- From fccb0e7887733542ee5eb6e6535121cab9f983bd Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Wed, 21 Sep 2022 01:13:24 -0400 Subject: [PATCH 04/10] passed_wave_3 --- tests/test_wave_01.py | 2 +- tests/test_wave_03.py | 15 +++++++++------ viewing_party/party.py | 4 ---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 8d0f2ee03..b46781d26 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -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_user_watchlist(): # Arrange movie = { diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 046429360..36f9a4575 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,16 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 + assert INTRIGUE_3 in friends_unique_movies + assert HORROR_1 in friends_unique_movies + assert FANTASY_4 in friends_unique_movies - 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 = { diff --git a/viewing_party/party.py b/viewing_party/party.py index b7e9e7be2..7784eaf75 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -77,10 +77,6 @@ def get_watched_avg_rating(user_data): def get_most_watched_genre(user_data): - # if len(user_data['watched'])==0: - # return None - - # else: fantasy_count=0 action_count=0 intrigue_count=0 From bdf83c82b7428ce6fe131903458e50013de6605d Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Wed, 21 Sep 2022 18:49:52 -0400 Subject: [PATCH 05/10] finished_wave_4 --- tests/test_wave_04.py | 6 +-- viewing_party/party.py | 94 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 94 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_04.py b/tests/test_wave_04.py index 499669077..67f432045 100644 --- a/tests/test_wave_04.py +++ b/tests/test_wave_04.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() + def test_get_available_friend_rec(): # Arrange amandas_data = clean_wave_4_data() @@ -16,7 +16,7 @@ def test_get_available_friend_rec(): assert FANTASY_4b in recommendations assert amandas_data == clean_wave_4_data() -@pytest.mark.skip() + def test_no_available_friend_recs(): # Arrange amandas_data = { @@ -38,7 +38,7 @@ def test_no_available_friend_recs(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() + def test_no_available_friend_recs_watched_all(): # Arrange amandas_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 7784eaf75..46c211538 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,5 +1,7 @@ + # ------------- WAVE 1 -------------------- + def create_movie(title, genre, rating): if title ==None: return None @@ -116,12 +118,98 @@ def get_most_watched_genre(user_data): # ------------- WAVE 3 -------------------- # ----------------------------------------- - + + +def get_unique_watched(user_data): + #dictionary['friends'][0]['watched'][movie_list][movie] + #if len(user_data)>0: + + #create total list of movies + list_of_watched_movies=[] + for friend in user_data['friends']: + for movie in friend['watched']: + list_of_watched_movies.append(movie) + + list_of_unique_movies=[] + #create list of unique movies + for watched_movie in user_data['watched']: + if watched_movie not in list_of_watched_movies: + list_of_unique_movies.append(watched_movie) + + return list_of_unique_movies +#write helper function + + +def get_friends_unique_watched(user_data): + + #get total list of all watched_movies + list_of_watched_movies=[] + for friend in user_data['friends']: + for movie in friend['watched']: + list_of_watched_movies.append(movie) + + + #create list of unique movies for friends + list_of_unique_movies=[] + for watched_movie in user_data['watched']: + if watched_movie not in list_of_watched_movies: + list_of_unique_movies.append(watched_movie) + + #list_of_watched_movies subtract list_of_unique_movies + friends_unique_movies=[] + for unique_movie in list_of_watched_movies: + if unique_movie not in user_data['watched']: + friends_unique_movies.append(unique_movie) + + #ensure no duplicates in friends_unique_movie_list + result=[] + for i in friends_unique_movies: + if i not in result: + result.append(i) + print(len(result)) + friends_unique_movies=result + + return friends_unique_movies + + + # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- +def get_available_recs(user_data): + + #get list of all movies like wave 3 (movies_to_recommend) + movies_to_recommend=[] + for friend in user_data['friends']: + for movie in friend['watched']: + movies_to_recommend.append(movie) + + #create list of all hosts that are available (all_available_hosts) + all_available_hosts=[] + for host in user_data["subscriptions"]: + all_available_hosts.append(host) + + #check movies meet conditions for being added to recommended_movie_list + recommended_movie_list=[] + + #checks 2 conditions for recommended movie (wave 3 function) + friends_unique_watched=get_friends_unique_watched(user_data) + + #check movies_to_recommend meet conditions for being recommended + if len(movies_to_recommend)>0: + for movie_to_recommend in movies_to_recommend: + + #check if host is available in friends["subscriptions"]_list + if movie_to_recommend['host'] not in all_available_hosts: + continue + + #Checks 2 conditions for recommended_movie_list -- not in user['watched'], is in user['friends']['watched'] + if movie_to_recommend in friends_unique_watched: + recommended_movie_list.append(movie_to_recommend) + + return recommended_movie_list + # ----------------------------------------- # ------------- WAVE 5 -------------------- -# ----------------------------------------- - +# ---------------------------------------- \ No newline at end of file From 3143db71a883f234f2917dbf8649666a5e3ae94b Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Thu, 22 Sep 2022 18:34:56 -0400 Subject: [PATCH 06/10] finished wave 5 --- tests/test_wave_05.py | 19 +++++++++------- viewing_party/party.py | 51 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 9 deletions(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index 85ebb8b18..7d81641cf 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -2,7 +2,7 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() +#@pytest.mark.skip() def test_new_genre_rec(): # Arrange sonyas_data = clean_wave_5_data() @@ -17,7 +17,7 @@ def test_new_genre_rec(): assert FANTASY_4b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() +pytest.mark.skip() def test_new_genre_rec_from_empty_watched(): # Arrange sonyas_data = { @@ -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,27 +52,30 @@ def test_new_genre_rec_from_empty_friends(): } ] } + 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 theis tests ********** # ********************************************************************* -@pytest.mark.skip() +pytest.mark.skip() def test_unique_rec_from_favorites(): # Arrange sonyas_data = clean_wave_5_data() # Act recommendations = get_rec_from_favorites(sonyas_data) - # Assert assert len(recommendations) == 2 assert FANTASY_2b in recommendations assert INTRIGUE_2b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() +#@pytest.mark.skip() def test_unique_from_empty_favorites(): # Arrange sonyas_data = { @@ -94,7 +97,7 @@ def test_unique_from_empty_favorites(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() +#@pytest.mark.skip() def test_new_rec_from_empty_friends(): # Arrange sonyas_data = { diff --git a/viewing_party/party.py b/viewing_party/party.py index 46c211538..6f3027a62 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -212,4 +212,53 @@ def get_available_recs(user_data): # ----------------------------------------- # ------------- WAVE 5 -------------------- -# ---------------------------------------- \ No newline at end of file +# ---------------------------------------- + +def get_new_rec_by_genre(user_data): + #get most_popular genre from user_data['watched']['genre'] + fav_genre=get_most_watched_genre(user_data) + + #call get_friends_unique_watched(user_data) to check conditions for recommendation_list + friends_unique_watched=get_friends_unique_watched(user_data) + + #filter list of friends_unique_watched by genre to generate recommended movie list by genre + rec_movie_list_by_genre=[] + for movie in friends_unique_watched: + if movie['genre']==fav_genre: + rec_movie_list_by_genre.append(movie) + return rec_movie_list_by_genre + +# #---------------------------------------------- +# #is get_friends_unique_watched function with user_data['favorites'], instead of user_data['watched'] +def get_rec_from_favorites(user_data): + + #get total list of all friends' watched_movies + movies_friends_have_watched=[] + for friend in user_data['friends']: + for movie in friend['watched']: + movies_friends_have_watched.append(movie) + + + #create list of user's favorite movies that is not in friends' watched movie_list + favorite_movies_list=[] + for favorite_movie in user_data['favorites']: + if favorite_movie not in movies_friends_have_watched: + favorite_movies_list.append(favorite_movie) + + #if movie is in favorite_movies + + # #list_of_watched_movies subtract list_of_unique_movies + # fav_movies_to_recommend=[] + # for unique_movie in list_of_watched_movies: + # if unique_movie not in user_data['favorites']: + # fav_movies_to_recommend.append(unique_movie) + + # #ensure no duplicates in friends_unique_movie_list + # result=[] + # for i in fav_movies_to_recommend: + # if i not in result: + # result.append(i) + # print(len(result)) + # fav_movies_to_recommend=result + + return favorite_movies_list From 25bcfaea2b0435e6904388de4b155060632357b1 Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Fri, 23 Sep 2022 11:33:58 -0400 Subject: [PATCH 07/10] removed unnecessary comments --- viewing_party/party.py | 29 +++-------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 6f3027a62..4f3b17ae3 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,6 +1,6 @@ # ------------- WAVE 1 -------------------- - +#------------------------------------------ def create_movie(title, genre, rating): if title ==None: @@ -10,7 +10,6 @@ def create_movie(title, genre, rating): elif rating== None: return None else: - new_movie = {'title': title, 'genre': genre, 'rating': rating} return new_movie @@ -33,8 +32,8 @@ def add_to_watched(user_data, movie): def add_to_watchlist(user_data, movie): #this function creates list of movies based on boolean condition== "watched" or !="watched" - #begin list of watched movies + #begin list of watched movies updated_data=user_data.copy() watch_list=[] @@ -45,14 +44,10 @@ def add_to_watchlist(user_data, movie): updated_data['watchlist']=watch_list print(updated_data) - #OUTPUT IS dictionary of list. Key is 'Watched" value is list of movies [index, movie] return updated_data def watch_movie(user_data, title): for movie in user_data["watchlist"]: - #removed assert statements below -- modified test to return original value for user_data - #assert movie_to_watch not in updated_data["watchlist"] - #assert movie_to_watch not in updated_data["watched"] if movie["title"] == title: user_data["watched"].append(movie) user_data["watchlist"].remove(movie) @@ -64,9 +59,7 @@ def watch_movie(user_data, title): # ------------- WAVE 2 -------------------- # ----------------------------------------- def get_watched_avg_rating(user_data): - #user_data is dictionary with a 'watched' list of movie - #user_data[watched][list_of_watched_movies] - #list_of_watched_movies[index][movie.dict] + sum=0 total_movies_in_list=0 if len(user_data['watched'])==0: @@ -244,21 +237,5 @@ def get_rec_from_favorites(user_data): for favorite_movie in user_data['favorites']: if favorite_movie not in movies_friends_have_watched: favorite_movies_list.append(favorite_movie) - - #if movie is in favorite_movies - - # #list_of_watched_movies subtract list_of_unique_movies - # fav_movies_to_recommend=[] - # for unique_movie in list_of_watched_movies: - # if unique_movie not in user_data['favorites']: - # fav_movies_to_recommend.append(unique_movie) - - # #ensure no duplicates in friends_unique_movie_list - # result=[] - # for i in fav_movies_to_recommend: - # if i not in result: - # result.append(i) - # print(len(result)) - # fav_movies_to_recommend=result return favorite_movies_list From 7e9e9c78b4f4b475cb886df71c10ea1fbdab576f Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Fri, 23 Sep 2022 11:50:03 -0400 Subject: [PATCH 08/10] removed additional comments --- viewing_party/party.py | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index 4f3b17ae3..b3257ab69 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -31,17 +31,15 @@ def add_to_watched(user_data, movie): return updated_data def add_to_watchlist(user_data, movie): -#this function creates list of movies based on boolean condition== "watched" or !="watched" - #begin list of watched movies updated_data=user_data.copy() + #create list of watched movies watch_list=[] - #add new movie to list watch_list.append(movie) print(watch_list) + #add list to dictionary - updated_data['watchlist']=watch_list print(updated_data) return updated_data @@ -77,26 +75,23 @@ def get_most_watched_genre(user_data): intrigue_count=0 horror_count=0 genre_dict=dict() - #print (type(genre_list)) - + + #create genre_count by genre, add to genre_dict[genre][genre_count] for movie in user_data["watched"]: if movie['genre']=='Fantasy': fantasy_count+=1 genre_dict['Fantasy']= fantasy_count elif movie['genre']=='Action': - #genre_list[action_count]+=1 action_count+=1 genre_dict['Action']=action_count elif movie['genre']=='Intrigue': - #genre_list[intrigue_count]+=1 intrigue_count+=1 genre_dict['Intrigue']=intrigue_count elif movie['genre']=='Horror': - #genre_list[horror_count]+=1 horror_count+=1 genre_dict['Horror']= horror_count - #max_count=max(genre_dict.values()) + #find max_count=max(genre_dict.values()) if len(genre_dict)==0: return None else: @@ -114,8 +109,7 @@ def get_most_watched_genre(user_data): def get_unique_watched(user_data): - #dictionary['friends'][0]['watched'][movie_list][movie] - #if len(user_data)>0: + #if len(user_data)>0 #create total list of movies list_of_watched_movies=[] @@ -135,20 +129,20 @@ def get_unique_watched(user_data): def get_friends_unique_watched(user_data): - #get total list of all watched_movies + #create total list of all watched_movies list_of_watched_movies=[] for friend in user_data['friends']: for movie in friend['watched']: list_of_watched_movies.append(movie) - #create list of unique movies for friends + #create list of unique movies for user list_of_unique_movies=[] for watched_movie in user_data['watched']: if watched_movie not in list_of_watched_movies: list_of_unique_movies.append(watched_movie) - #list_of_watched_movies subtract list_of_unique_movies + #from list_of_watched_movies subtract list_of_unique_movies friends_unique_movies=[] for unique_movie in list_of_watched_movies: if unique_movie not in user_data['watched']: @@ -172,7 +166,7 @@ def get_friends_unique_watched(user_data): def get_available_recs(user_data): - #get list of all movies like wave 3 (movies_to_recommend) + #create list of all movies like wave 3 (movies_to_recommend) movies_to_recommend=[] for friend in user_data['friends']: for movie in friend['watched']: @@ -183,7 +177,7 @@ def get_available_recs(user_data): for host in user_data["subscriptions"]: all_available_hosts.append(host) - #check movies meet conditions for being added to recommended_movie_list + #create recommended_movie_list to return recommended_movie_list=[] #checks 2 conditions for recommended movie (wave 3 function) @@ -193,11 +187,11 @@ def get_available_recs(user_data): if len(movies_to_recommend)>0: for movie_to_recommend in movies_to_recommend: - #check if host is available in friends["subscriptions"]_list + #if host is available in friends["subscriptions"]_list if movie_to_recommend['host'] not in all_available_hosts: continue - #Checks 2 conditions for recommended_movie_list -- not in user['watched'], is in user['friends']['watched'] + #if not in user['watched'] and is in user['friends']['watched'] if movie_to_recommend in friends_unique_watched: recommended_movie_list.append(movie_to_recommend) @@ -221,8 +215,8 @@ def get_new_rec_by_genre(user_data): rec_movie_list_by_genre.append(movie) return rec_movie_list_by_genre -# #---------------------------------------------- -# #is get_friends_unique_watched function with user_data['favorites'], instead of user_data['watched'] +# ---------------------------------------------- +# is sim to get_friends_unique_watched function with user_data['favorites'], instead of user_data['watched'] def get_rec_from_favorites(user_data): #get total list of all friends' watched_movies From 8881667407bc764b01f638d2958faff5d2b834f6 Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Fri, 23 Sep 2022 11:53:35 -0400 Subject: [PATCH 09/10] removed indentation issue from wave 3 --- viewing_party/party.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index b3257ab69..b86130dcd 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -109,21 +109,20 @@ def get_most_watched_genre(user_data): def get_unique_watched(user_data): - #if len(user_data)>0 - #create total list of movies - list_of_watched_movies=[] - for friend in user_data['friends']: - for movie in friend['watched']: - list_of_watched_movies.append(movie) + #create total list of movies + list_of_watched_movies=[] + for friend in user_data['friends']: + for movie in friend['watched']: + list_of_watched_movies.append(movie) - list_of_unique_movies=[] - #create list of unique movies - for watched_movie in user_data['watched']: - if watched_movie not in list_of_watched_movies: - list_of_unique_movies.append(watched_movie) + list_of_unique_movies=[] + #create list of unique movies + for watched_movie in user_data['watched']: + if watched_movie not in list_of_watched_movies: + list_of_unique_movies.append(watched_movie) - return list_of_unique_movies + return list_of_unique_movies #write helper function From cb6d23066aa5cd1ae478db43bc3484a51db27008 Mon Sep 17 00:00:00 2001 From: n2020h <72112832+n2020h@users.noreply.github.com> Date: Fri, 23 Sep 2022 11:57:48 -0400 Subject: [PATCH 10/10] tigers Neema viewing party ready to submit --- viewing_party/party.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index b86130dcd..3e40f0e5c 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -106,8 +106,6 @@ def get_most_watched_genre(user_data): # ------------- WAVE 3 -------------------- # ----------------------------------------- - - def get_unique_watched(user_data): #create total list of movies