From 0034ac953031f56bec22174a5fa8c97d32d1235a Mon Sep 17 00:00:00 2001 From: Wenling Date: Tue, 8 Nov 2022 11:59:13 -0500 Subject: [PATCH 01/10] testing PAT --- README.md | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 187cdb442..071b7a5e7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Viewing Party +Date: 2022/11/08 + ## Skills Assessed Solving problems with... @@ -28,11 +30,11 @@ Follow these directions once, a the beginning of your project: $ cd ~/Developer/projects ``` -2. In Github click on the "Fork" button in github and fork the repository to your Github account. This will make a copy of the project in your github account. +2. In Github click on the "Fork" button in github and fork the repository to your Github account. This will make a copy of the project in your github account. ![Fork Button](images/fork.png) -3. "Clone" (download a copy of this project) into your projects folder. This command makes a new folder called `viewing-party`, and then puts the project into this new folder. Make sure you are cloning from your copy of the project and not the class version (ada-cX). +3. "Clone" (download a copy of this project) into your projects folder. This command makes a new folder called `viewing-party`, and then puts the project into this new folder. Make sure you are cloning from your copy of the project and not the class version (ada-cX). ```bash $ git clone ... @@ -92,22 +94,23 @@ $ source venv/bin/activate 2. Check the `tests` folder, and find the test file you want to run - In that test file, read through each test case - - If it is incomplete, complete the test. - - *Is this a nominal or edge case?* - - *What type of input do we need to test this case?* - - *What is the expected output for the given input?* + - If it is incomplete, complete the test. + - _Is this a nominal or edge case?_ + - _What type of input do we need to test this case?_ + - _What is the expected output for the given input?_ - Remove the lines that contain `@pytest.mark.skip()` for the test(s) you want to run. 3. Run the test(s)! - - *See the [Details About How to Run Tests](#details-about-how-to-run-tests) section below for more information on how to run test(s).* + - _See the [Details About How to Run Tests](#details-about-how-to-run-tests) section below for more information on how to run test(s)._ ```bash # Must be in activated virtual environment in the project-root directory $ pytest ``` -4. Read through the test failure, and understand why the failure is happening. Confirm your findings with a classmate. - - If it is a test you wrote, consider whether you are actually testing what you intend to test. Does the test need modification? +4. Read through the test failure, and understand why the failure is happening. Confirm your findings with a classmate. + + - If it is a test you wrote, consider whether you are actually testing what you intend to test. Does the test need modification? 5. Make a plan to implement code to pass the test. @@ -122,8 +125,9 @@ $ pytest 10. Consider looking for opportunities to improve your code. 11. Before moving to the next wave, make sure you haven't missed any skipped tests. - - *Search the file (**Cmd** **F**) for `@pytest.mark.skip`* - - *To search all files in the project, use **Cmd** **Shift** **F*** + + - _Search the file (**Cmd** **F**) for `@pytest.mark.skip`_ + - \*To search all files in the project, use **Cmd** **Shift** **F\*** 12. Begin using the test file of the next wave! @@ -135,8 +139,6 @@ $ deactivate Finally, at submission time, **no matter where you are**, submit the project via Learn. - - This will let us give feedback on what you've finished so that you can be better prepared for the next project. ## Details About How to Run Tests @@ -186,13 +188,13 @@ To run this file, use: python3 play_tester.py ``` -There is some starter code provided in `play_tester.py`. This code prints the test data that is used for many of the tests. Looking closely at this data can help us think critically about the expected output for given input for each function. Then, calling each function with this data allows us to observe the **actual** output for given input. +There is some starter code provided in `play_tester.py`. This code prints the test data that is used for many of the tests. Looking closely at this data can help us think critically about the expected output for given input for each function. Then, calling each function with this data allows us to observe the **actual** output for given input. ## Test Data -We will note that much of the test data for this project is provided by the file `test_constants.py`. As test data gets more and more complex, it is helpful to organize this data in its own file to enhance consistency and readability. Pytest, like many testing libraries, provide a special too for test data called **fixtures**. We will learn about fixtures later in the curriculum. +We will note that much of the test data for this project is provided by the file `test_constants.py`. As test data gets more and more complex, it is helpful to organize this data in its own file to enhance consistency and readability. Pytest, like many testing libraries, provide a special too for test data called **fixtures**. We will learn about fixtures later in the curriculum. -For the time being, we need to make sure that the data provided to each test is clean and free of any changes that running another test may have introduced. Recall the *Modifying Mutable Objects* section of the *Variables Are References lesson.* To ensure that the data for each test is storied in a unique place in memory, there are functions implemented in `test_constants.py` that provide clean test data (i.e. `clean_wave_3_data`) by using `copy.deepcopy`. +For the time being, we need to make sure that the data provided to each test is clean and free of any changes that running another test may have introduced. Recall the _Modifying Mutable Objects_ section of the _Variables Are References lesson._ To ensure that the data for each test is storied in a unique place in memory, there are functions implemented in `test_constants.py` that provide clean test data (i.e. `clean_wave_3_data`) by using `copy.deepcopy`. ## Project Directions @@ -202,7 +204,7 @@ When our test failures leave us confused and stuck, let's use the detailed proje ### Wave 1 -1. Create a function named `create_movie`. This function and all subsequent functions should be in `party.py`. `create_movie` should... +1. Create a function named `create_movie`. This function and all subsequent functions should be in `party.py`. `create_movie` should... - take three parameters: `title`, `genre`, `rating` - If those three attributes are truthy, then return a dictionary. This dictionary should... @@ -320,7 +322,7 @@ Note: For Waves 2, 3, 4, and 5, your implementation of each of the functions sho ### Wave 5 -1. Create a function named `get_new_rec_by_genre`. This function should... +1. Create a function named `get_new_rec_by_genre`. This function should... - take one parameter: `user_data` - Consider the user's most frequently watched genre. Then, determine a list of recommended movies. A movie should be added to this list if and only if: @@ -329,7 +331,7 @@ Note: For Waves 2, 3, 4, and 5, your implementation of each of the functions sho - The `"genre"` of the movie is the same as the user's most frequent genre - Return the list of recommended movies -2. Create a function named `get_rec_from_favorites`. This function should... +2. Create a function named `get_rec_from_favorites`. This function should... - take one parameter: `user_data` - `user_data` will have a field `"favorites"`. The value of `"favorites"` is a list of movie dictionaries From 9e8d4cb800652bc38c4d33a1118960cdaf1ce363 Mon Sep 17 00:00:00 2001 From: Wenling Date: Tue, 8 Nov 2022 12:05:27 -0500 Subject: [PATCH 02/10] testing PAT --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 071b7a5e7..92e649da8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Viewing Party Date: 2022/11/08 +Wenling Yu ## Skills Assessed From 68049a54eba97feaafd1a4bba5963d068832ca4b Mon Sep 17 00:00:00 2001 From: Wenling Date: Tue, 8 Nov 2022 12:15:05 -0500 Subject: [PATCH 03/10] test --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 92e649da8..071b7a5e7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # Viewing Party Date: 2022/11/08 -Wenling Yu ## Skills Assessed From 1c02bbc7d26d8e4d3c47b3f46da900186f6899a8 Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 12:15:18 -0500 Subject: [PATCH 04/10] create_movie function --- README.md | 2 -- tests/test_wave_01.py | 8 ++++---- viewing_party/party.py | 15 +++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 071b7a5e7..7114b0879 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # Viewing Party -Date: 2022/11/08 - ## Skills Assessed Solving problems with... diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 6be6994a5..96bba7a7e 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() + 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() + 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() + 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() + def test_create_no_rating_movie(): # Arrange movie_title = "Title A" diff --git a/viewing_party/party.py b/viewing_party/party.py index 6d34a6b5f..f8bc5e4b5 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -1,8 +1,23 @@ # ------------- WAVE 1 -------------------- def create_movie(title, genre, rating): + if title == None or genre == None or rating == None: + return None + dict = {} + dict["title"] = title + dict["genre"] = genre + dict["rating"] = rating + return dict + + +def add_to_watched(user_data, movie): + pass + +def add_to_watchlist(): pass +def watch_movie(): + pass # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From e7aedea1023e0d77b179a9fb2ec8abe7ba5592a6 Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 12:19:09 -0500 Subject: [PATCH 05/10] add)to_watched function --- viewing_party/party.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/viewing_party/party.py b/viewing_party/party.py index f8bc5e4b5..693028eb2 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -11,7 +11,8 @@ def create_movie(title, genre, rating): def add_to_watched(user_data, movie): - pass + user_data["watched"].append(movie) + return user_data def add_to_watchlist(): pass From b4f0d36e78770e497f31a61ad79fbeb40b48a4ed Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 12:51:59 -0500 Subject: [PATCH 06/10] finish wave1 --- tests/test_wave_01.py | 19 +++++++++++-------- viewing_party/party.py | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/test_wave_01.py b/tests/test_wave_01.py index 96bba7a7e..a47da6909 100644 --- a/tests/test_wave_01.py +++ b/tests/test_wave_01.py @@ -58,7 +58,6 @@ def test_create_no_rating_movie(): # Assert assert new_movie is None -@pytest.mark.skip() def test_adds_movie_to_user_watched(): # Arrange movie = { @@ -79,7 +78,6 @@ 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() def test_adds_movie_to_user_watchlist(): # Arrange movie = { @@ -100,7 +98,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() + def test_moves_movie_from_watchlist_to_empty_watched(): # Arrange janes_data = { @@ -119,12 +117,13 @@ def test_moves_movie_from_watchlist_to_empty_watched(): assert len(updated_data["watchlist"]) == 0 assert len(updated_data["watched"]) == 1 - raise Exception("Test needs to be completed.") + #raise Exception("Test needs to be completed.") + assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* -@pytest.mark.skip() + def test_moves_movie_from_watchlist_to_watched(): # Arrange movie_to_watch = HORROR_1 @@ -142,13 +141,17 @@ def test_moves_movie_from_watchlist_to_watched(): # Assert assert len(updated_data["watchlist"]) == 1 assert len(updated_data["watched"]) == 2 - - raise Exception("Test needs to be completed.") + + #raise Exception("Test needs to be completed.") + assert updated_data["watched"][1] == movie_to_watch + assert updated_data["watchlist"][0] != movie_to_watch # ******************************************************************************************* # ****** Add assertions here to test that the correct movie was added to "watched" ********** # ******************************************************************************************* + + + -@pytest.mark.skip() def test_does_nothing_if_movie_not_in_watchlist(): # Arrange movie_to_watch = HORROR_1 diff --git a/viewing_party/party.py b/viewing_party/party.py index 693028eb2..2dfe2f9a0 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -14,11 +14,19 @@ def add_to_watched(user_data, movie): user_data["watched"].append(movie) return user_data -def add_to_watchlist(): - pass +def add_to_watchlist(user_data, movie): + user_data["watchlist"].append(movie) + return user_data + +def watch_movie(user_data, title): + for i in range(len(user_data["watchlist"])): + if user_data["watchlist"][i]["title"] == title: + add_to_watched(user_data, user_data["watchlist"][i]) + del user_data["watchlist"][i] + break + return user_data -def watch_movie(): - pass + # ----------------------------------------- # ------------- WAVE 2 -------------------- # ----------------------------------------- From e8003235827f9f7dda6d1aad8b4adec349d1a85b Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 16:11:58 -0500 Subject: [PATCH 07/10] finish wave2 --- tests/test_wave_02.py | 4 ---- viewing_party/party.py | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/tests/test_wave_02.py b/tests/test_wave_02.py index 3a588299e..b0d363d9d 100644 --- a/tests/test_wave_02.py +++ b/tests/test_wave_02.py @@ -2,7 +2,6 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() def test_calculates_watched_average_rating(): # Arrange janes_data = clean_wave_2_data() @@ -14,7 +13,6 @@ def test_calculates_watched_average_rating(): assert average == pytest.approx(3.58333) assert janes_data == clean_wave_2_data() -@pytest.mark.skip() def test_empty_watched_average_rating_is_zero(): # Arrange janes_data = { @@ -27,7 +25,6 @@ def test_empty_watched_average_rating_is_zero(): # Assert assert average == pytest.approx(0.0) -@pytest.mark.skip() def test_most_watched_genre(): # Arrange janes_data = clean_wave_2_data() @@ -39,7 +36,6 @@ def test_most_watched_genre(): assert popular_genre == "Fantasy" assert janes_data == clean_wave_2_data() -@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 2dfe2f9a0..9a37cb5c9 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -31,6 +31,30 @@ def watch_movie(user_data, title): # ------------- WAVE 2 -------------------- # ----------------------------------------- +def get_watched_avg_rating(user_data): + sum_rating = 0.0 + tot_watched = len(user_data["watched"]) + if tot_watched ==0: + return 0.0 + for i in range(tot_watched): + sum_rating = sum_rating + user_data["watched"][i]["rating"] + return sum_rating/tot_watched + +def get_most_watched_genre(user_data): + if len(user_data["watched"]) == 0: + return None + genres = {} + for i in range(len(user_data["watched"])): + temp_genre = user_data["watched"][i]["genre"] + if temp_genre in genres: + genres[temp_genre] += 1 + else: + genres[temp_genre] = 1 + most_watched_genre = max(genres, key=genres.get) + + return most_watched_genre + + # ----------------------------------------- # ------------- WAVE 3 -------------------- From 54d762cc0398ca92cead7a3c95af504de8eea398 Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 20:43:12 -0500 Subject: [PATCH 08/10] finish wave3 --- tests/test_wave_03.py | 9 +++------ viewing_party/party.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/tests/test_wave_03.py b/tests/test_wave_03.py index 046429360..2cee1ab9f 100644 --- a/tests/test_wave_03.py +++ b/tests/test_wave_03.py @@ -2,7 +2,6 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() def test_my_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -16,7 +15,6 @@ def test_my_unique_movies(): assert INTRIGUE_2 in amandas_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() def test_my_not_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -28,7 +26,6 @@ def test_my_not_unique_movies(): # Assert assert len(amandas_unique_movies) == 0 -@pytest.mark.skip() def test_friends_unique_movies(): # Arrange amandas_data = clean_wave_3_data() @@ -43,7 +40,6 @@ def test_friends_unique_movies(): assert FANTASY_4 in friends_unique_movies assert amandas_data == clean_wave_3_data() -@pytest.mark.skip() def test_friends_unique_movies_not_duplicated(): # Arrange amandas_data = clean_wave_3_data() @@ -55,12 +51,13 @@ def test_friends_unique_movies_not_duplicated(): # Assert assert len(friends_unique_movies) == 3 - raise Exception("Test needs to be completed.") + #raise Exception("Test needs to be completed.") + assert HORROR_1 in friends_unique_movies + assert INTRIGUE_3 in friends_unique_movies # ************************************************************************************************* # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** # ************************************************************************************************** -@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 9a37cb5c9..30d40f21b 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -59,6 +59,47 @@ def get_most_watched_genre(user_data): # ----------------------------------------- # ------------- WAVE 3 -------------------- # ----------------------------------------- +# {watched:[{},{}..], friends:[{watched:[{movie:{title}}...]},{}] } + +def get_unique_watched(user_data): + friends_watch = [] + user_watch = [] + result = [] + for friend in user_data["friends"]: + for movie in friend["watched"]: + friends_watch.append(movie["title"]) + + for movie in user_data["watched"]: + user_watch.append(movie["title"]) + + my_unique_title = list(set(user_watch)-set(friends_watch)) + for movie in user_data["watched"]: + if movie["title"] in my_unique_title: + result.append(movie) + + return result + + +def get_friends_unique_watched(user_data): + friends_watch = [] + user_watch = [] + result = [] + for friend in user_data["friends"]: + for movie in friend["watched"]: + friends_watch.append(movie["title"]) + + for movie in user_data["watched"]: + user_watch.append(movie["title"]) + + friend_unique_title = list(set(friends_watch)-set(user_watch)) + + for friend in user_data["friends"]: + for movie in friend["watched"]: + if movie["title"] in friend_unique_title and movie not in result: + result.append(movie) + + return result + # ----------------------------------------- From 8a7eb6c71372a62c2f2fc9b9b2bc855f268cd2fe Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 22:28:24 -0500 Subject: [PATCH 09/10] finish wave4 --- tests/test_wave_04.py | 3 --- viewing_party/party.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_wave_04.py b/tests/test_wave_04.py index 499669077..8431f3078 100644 --- a/tests/test_wave_04.py +++ b/tests/test_wave_04.py @@ -2,7 +2,6 @@ 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 +15,6 @@ 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 +36,6 @@ 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 30d40f21b..ed5fbeda4 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -105,6 +105,16 @@ def get_friends_unique_watched(user_data): # ----------------------------------------- # ------------- WAVE 4 -------------------- # ----------------------------------------- +# user_data={subscriptions:[], friends:[{watched:{movie: {host:xxx}}},{}] } +def get_available_recs(user_data): + recommended_movies = [] + only_friends_watched = get_friends_unique_watched(user_data) + for movie in only_friends_watched: + if (movie["host"] in user_data["subscriptions"]): + recommended_movies.append(movie) + + return recommended_movies + # ----------------------------------------- # ------------- WAVE 5 -------------------- From cadb2489eb77203527f221f18b1b8d10d1a618a9 Mon Sep 17 00:00:00 2001 From: Wenling Date: Wed, 9 Nov 2022 22:48:02 -0500 Subject: [PATCH 10/10] finish wave 5 --- tests/test_wave_05.py | 13 ++++++------- viewing_party/party.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tests/test_wave_05.py b/tests/test_wave_05.py index 85ebb8b18..c6d47bba3 100644 --- a/tests/test_wave_05.py +++ b/tests/test_wave_05.py @@ -2,7 +2,6 @@ from viewing_party.party import * from tests.test_constants import * -@pytest.mark.skip() def test_new_genre_rec(): # Arrange sonyas_data = clean_wave_5_data() @@ -17,7 +16,6 @@ def test_new_genre_rec(): assert FANTASY_4b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() def test_new_genre_rec_from_empty_watched(): # Arrange sonyas_data = { @@ -38,7 +36,6 @@ def test_new_genre_rec_from_empty_watched(): # Assert assert len(recommendations) == 0 -@pytest.mark.skip() def test_new_genre_rec_from_empty_friends(): # Arrange sonyas_data = { @@ -53,12 +50,16 @@ def test_new_genre_rec_from_empty_friends(): ] } - raise Exception("Test needs to be completed.") + # raise Exception("Test needs to be completed.") + # Act + recommendations = get_new_rec_by_genre(sonyas_data) + # Assert + assert len(recommendations) == 0 + # ********************************************************************* # ****** Complete the Act and Assert Portions of theis tests ********** # ********************************************************************* -@pytest.mark.skip() def test_unique_rec_from_favorites(): # Arrange sonyas_data = clean_wave_5_data() @@ -72,7 +73,6 @@ def test_unique_rec_from_favorites(): assert INTRIGUE_2b in recommendations assert sonyas_data == clean_wave_5_data() -@pytest.mark.skip() def test_unique_from_empty_favorites(): # Arrange sonyas_data = { @@ -94,7 +94,6 @@ def test_unique_from_empty_favorites(): # Assert assert len(recommendations) == 0 -@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 ed5fbeda4..194930c15 100644 --- a/viewing_party/party.py +++ b/viewing_party/party.py @@ -120,3 +120,20 @@ def get_available_recs(user_data): # ------------- WAVE 5 -------------------- # ----------------------------------------- +def get_new_rec_by_genre(user_data): + recommended_movies = [] + most_genre = get_most_watched_genre(user_data) + only_friends_watched = get_friends_unique_watched(user_data) + for movie in only_friends_watched: + if movie["genre"] == most_genre: + recommended_movies.append(movie) + return recommended_movies + +# {favorites:[{},..] } +def get_rec_from_favorites(user_data): + recommend_movies = [] + only_user_watched = get_unique_watched(user_data) + for movie in only_user_watched: + if movie in user_data["favorites"]: + recommend_movies.append(movie) + return recommend_movies