AntonioMrtz / SpotifyElectron

Spotify Electron is a cross-platform music streaming desktop app made with Electron-React frontend and Python-FastAPI-MongoDB Backend. The goal is to reproduce the original Spotify functionality while adding new ones like uploading songs.
https://antoniomrtz.github.io/SpotifyElectron_Web/
Other
41 stars 14 forks source link

Differentiate between BaseUser and User #159

Open AntonioMrtz opened 3 months ago

AntonioMrtz commented 3 months ago

Description

Differentiate between BaseUser and User by creating a Base class for all users and a User class that implements it, just like Artist is doing it at the moment.

Context

User class serves as BaseUser class and Artist inherits from it. The issue appears when trying to implement new users like for example an admin. This type of user doesnt care about fields such as playback_history and so.

Currently User class is both a Base class and a Concrete one. This can lead to confusion because other inheritances in the app such as songs have a Base and Concrete class that are not the same.

The aim is to:

Watch below for more info about the attributes:

@dataclass
class UserDAO:
    """Represents  user data in the persistence layer"""

    name: str - common
    photo: str - common
    register_date: str - common
    password: bytes - common
    playback_history: list[str] - user and its children classes
    playlists: list[str] - user and its children classes
    saved_playlists: list[str] - user and its children classes

@dataclass
class ArtistDAO(UserDAO):
    """Represents artist data in the persistence layer"""

    uploaded_songs: list[str] - artist and its children classes

How to do it

Testing

AntonioMrtz commented 3 months ago

Create Base User as Abstract

AlesSust commented 2 days ago

Hi @AntonioMrtz. I saw your issue and I would like to contribute to project Would you assign this to me? :)

AntonioMrtz commented 1 day ago

Hi @AlesSust , welcome to the project and thanks for your time. Sure, I will asign you to the issue. Let me know if you need anything :).We have a website with the project docs for set up the app and related topics. If you find this project interesting/helpful, I'd appreciate it if you could star the repo!