Wiredcraft / test-backend

39 stars 76 forks source link

Submission by Sebastian Scheibe #66

Closed Ecostack closed 3 years ago

Ecostack commented 3 years ago

This is the submission for the Wiredcraft Test Backend assignment.

Please see the README.md for more information on the project can be started.

It can be seen live on this URL: https://wiredcraft.techstack.de/ Best to start with the API documentation: https://wiredcraft.techstack.de/api

This is still work in progress for some things, so please bear with me.

Ecostack commented 3 years ago

I will put the PR into ready for review, although I will update the e2e tests and will add further code comments.

JuhaS commented 3 years ago

@Ecostack I would like to see if how you would improve the friend follow implementation in terms of making it cleaner solution (not adding more features), related to friend.repository.ts.

Ecostack commented 3 years ago

I assume this is regarding the PostgreSQL implementation and its way of maintaining the relationship between users.

I see potential in removing the OR clause in case both user ids are available. If the order of user ids is always the same, for example by sorting them, the userId and otherUserId will always be the same for a record. With that in place, the CREATE, FIND and DELETE operation, which involve two ids, can be made easier.

It would be like:

User (id: 546) creates friendship with user (id: 325). Ids sorted ascending, the friendship record is created with userId (325) and otherUserId (546). Same order would be applied if user id (325) creates/finds/deletes the record.

Further on, the status of a friendship only allows created and deleted. It would be great to add a status attribute to it.