GET/followings -> all following relations in followings table
GET/timelines/:follower_user_id(uint) -> Gets all users followed by a given user
GET/followers/:followed_user_id(uint) -> Gets all users following a given user
POST/followings: {following_user_id : uint,
followed_user_id : uint} -> Creates a following relation
DELETE/followings/:follower_user_id/:followed_user_id -> Deletes a following relation between two users
Please include a summary of the changes and the related issue. Please also include relevant motivation, context, and images! If its a frontend ticket, screenshots are important, if its a backend ticket, please add pictures of relevant postman screenshots or console printouts.
CHANGES:
2_FOLLOWING_V1.sql:
Refactored name of table from following to followings
Refactored name of time stamp to created_at
services/followings.go:
Added services for each endpoint
models/followings.go
Added a model representing a followings relation
controllers/followings.go
Added a controller for each endpoint
Description
Crud routes for the followings table:
Endpoints:
GET/followings -> all following relations in followings table GET/timelines/:follower_user_id(uint) -> Gets all users followed by a given user GET/followers/:followed_user_id(uint) -> Gets all users following a given user POST/followings: {following_user_id : uint, followed_user_id : uint} -> Creates a following relation DELETE/followings/:follower_user_id/:followed_user_id -> Deletes a following relation between two users
Change below here
Link to Ticket
Please include a summary of the changes and the related issue. Please also include relevant motivation, context, and images! If its a frontend ticket, screenshots are important, if its a backend ticket, please add pictures of relevant postman screenshots or console printouts. CHANGES: 2_FOLLOWING_V1.sql: Refactored name of table from following to followings Refactored name of time stamp to created_at
services/followings.go: Added services for each endpoint
models/followings.go Added a model representing a followings relation
controllers/followings.go Added a controller for each endpoint
routes/followings.go Initialized followings endpoint routes
How Has This Been Tested?
I have not written unit tests, but checked behaviorally through the API calls shown below.
Check followings retrieval: GET: /followings->![image](https://github.com/GenerateNU/Algo/assets/116120547/2b74e09d-7f46-44ed-8be5-87b69326fcdc)
POST: /followings/8/1: Create a following from user 8 to user 1:![image](https://github.com/GenerateNU/Algo/assets/116120547/33d614b7-8cae-44a4-a84e-e48772bebcaf)
GET: timelines/8 : Check timeline for user 8 to confirm user 1 is present![image](https://github.com/GenerateNU/Algo/assets/116120547/89fe5dc5-1d92-4bc5-8e3a-c58111e3726d)
GET: followers/1: Check user 1 followers to confirm 8 is present![image](https://github.com/GenerateNU/Algo/assets/116120547/8a8d5fa1-d1f6-4100-b088-3cc0125d9aa1)
DELETE: followings/8/1 -> Delete relation between 8 and 1![image](https://github.com/GenerateNU/Algo/assets/116120547/ad788d11-46f0-4557-93eb-9a85d62051ca)
Checklist