###### tags: `task` # Week 08 - Wrap up ## 1 Add Status filter in fetch tasks of a project. We have already implemented endpoint to return list of tasks of a project `api/mobile/v1/projects/{id}/tasks` now implement the following: - If no status passed as query string param in url, then return all list of tasks - If status passed ex: `api/mobile/v1/projects/{id}/tasks?status=to_do`: then return only the tasks that its status is `to_do`, and so on for other statuses. ![image](https://hackmd.io/_uploads/BkjU7PGQ1g.png) ## 2 Implement Endpoints for Dashboard/Statistics data ![image](https://hackmd.io/_uploads/H1bW4DGQ1l.png) ### Implement one endpoint to return statistics data for a client/Freelancer endpoint `api/mobile/v1/GetMyStatistics` Data in the Response shoule be like below: ```jsonld { Projects:{ Total:7, Available:2, Closed:5 }, Tasks:{ Total:21, ToDo:'23%', InReview:"Y%" InProgress:"44%". Done:"X%" } } ``` NOTE: We will return projectt status `Available` and `Closed` instead of `Pending`, 'In Progress', `Done` ## 3 Re-implement Skills for a freelancer We implemented skills as string property in the Freelancer user type, however, we need to seperate skills as list: ### Step 1, Remove Skills string from freelancer entity - this require to review all the code and remove any usage for this proprty - Remove skills from DTOs like, register DTO, during register we don't need from the user to upload his skills. ### Step 2, Define new Entity Called `Skill` Columns: - Id: Pk - UserId: FK of freelancer - Name: name of the skill Implement the relationship betwee freelancer and Skill by Data annotation or fluent API, each Freelancer have many skills. (1-m relattionship) Do the migration to create new table called `Skills`. ### Implement new endpoints to Add or Remove Skills 1. `api/mobile/v1/users/{id}/skills` POST to for adding 2. `api/mobile/v1/users/{id}/skills` REMOVE to for removing skill Hints: - Validate the requestor user id is the same as passed in the URL(because another user should be able to remove or add skill for other user) ## 4 (Bonus) Modify endpoints of projects filter Freelancer have diffetent options to filter on projects in the feed as below: ![image](https://hackmd.io/_uploads/Sy11KvGQkx.png) Propose, design and implement this by yourself :). ## 5(Bonus) `Like` feature Lets implement a "like" feature for projects of clients, so each user `Client` or `Freelancer` is able to add like to the project publiched by a client. each user should be able to like the project once, remove it. also we should return number of likes for a project and in the returned projects list. ![image](https://hackmd.io/_uploads/H1J_XDfQJg.png) ### Step 1, Entity and Database Migration Create new Entity/table called `ProjectLikes` with following columns: - Id: pk of the table. - ProjectId: fk of projects, represent the project that have this like - UserId: fk, represent the user who like this project - CreatedAt: datetime of the like action. **Hint**: add unique constraints for `ProjectId` + `UserId`, read about this if you don't know about it. Migrate new changes, new table should be created in the database. ### Step 2, Implement endpoint for like/unlike Implement new endpoint `/api/mobile/v1/projects/{pid}/like`, Http verb is POST Send in the body action (`like`,`unlike`) **Hints**: - you can read UserId from current authorized user who is making the request. - User/Actor allowed to be freelancer/client - publisher could like his project normally. - when action is `like`, validate and check that the user is never `like` this project before.(using unique constraint + logic validation) ### Step 3, Return number of likes for each project Go back to any endpoint that return projects details, include number of likes propery to be returned for the front-end example: list of projects that is returned to the front should have new property `likes` as count.