SE310-1 / W.A.K

W.A.K is a movie tracker web-app developed to simplify and enhance the movie-rating experience while making this process more fun and customisable.
MIT License
2 stars 12 forks source link

Ahop089 modal #87

Closed MRlolface249 closed 1 year ago

MRlolface249 commented 1 year ago

This pull request contributes to #80 and adds functionality which when an account is created a default profile picture is added to the users account, after which any time you add a movie to your favourites list, your profile picture will be replaced with this movie if it is the only movie in your list. Whenever you remove a movie from the list if the list becomes empty your profile picture goes back to the default image, if not it checks that the set profile picture is still in the list, and if it is not it changes, the profile picture to another movie in your favourites list.

image

klam656 commented 1 year ago

Hello Alex. Good effort! I can see you trying to implement profile picture field using mongoDB. and here is my thought. I will let you know what I understand so far and give you some suggestion.

My understanding of your implementation:

First, when the user add a movie in their favourite list, the movie ID will be added in the Profile Picture (pfp).

Screenshot 2023-10-18 at 9 53 00 AM

Then, user pfp will display the FIRST movie that uses add in their favourite list ( = first in pfp database), which you demonstrate here, you want to get the first item ([0] index) in the pfp database.

Screenshot 2023-10-18 at 9 45 00 AM

My thought:

Let's start with database structure. I found out that the favourite and the profilePicture field are most likely identical. (see in userModal)

Screenshot 2023-10-18 at 9 57 42 AM Screenshot 2023-10-18 at 9 57 58 AM

I think the pfp in the userModal field here can be consider as duplicated in this point. it does not have unique property here, therefore it might not be necessary to have its own field. We can just use the favourite field (in mongoDB) to get the movie image (using movieId).

Suggestion

Instead of creating a new profile field in the database, it will be more efficient just to use favourites, as the pfp is really depends on the movie in the favourite list. By doing so, this line of code might not be necessary, which reduce the complexity of the code.

Screenshot 2023-10-18 at 10 05 15 AM

Furthermore, we also need to think about if the user does not have movie in the favourite list yet, There is two approach can solve this issue.

First, we simply use the default pfp, which I am using now. OR Second, you can create a unique pfp (like Luca suggested last time - the github pfp or random movie) when the user signing up. In this case pfp field in MongoDB can be used to store the url for the generated pfp.

MRlolface249 commented 1 year ago

These issues have been accounted for, the "duplicate code" still remains but this is because they are unique and have different implementations, it is however true that they could possibly both use a shared helper function to avoid duplicate code