GenerateNU / Algo

Fullstack application for the Algo project
6 stars 0 forks source link

Following crud #23

Closed CamPlume1 closed 4 months ago

CamPlume1 commented 4 months ago

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

POST: /followings/8/1: Create a following from user 8 to user 1: image

GET: timelines/8 : Check timeline for user 8 to confirm user 1 is present image

GET: followers/1: Check user 1 followers to confirm 8 is present image

DELETE: followings/8/1 -> Delete relation between 8 and 1 image

Checklist

leoRysing commented 4 months ago

lgtm! Just changed follwed_user_id to following_user_id to account for changes in main